Adjusting the coding format as suggested in:

https://github.com/AppleCommander/AppleCommander/pull/19#pullrequestreview-82711570
This commit is contained in:
Lisias 2018-01-07 19:12:46 -02:00
parent 5c77c57aa2
commit ae66b88e0a
3 changed files with 86 additions and 71 deletions

View File

@ -288,13 +288,15 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
if (files != null) { if (files != null) {
for (int i=0; i<files.size(); i++) { for (int i=0; i<files.size(); i++) {
FileEntry entry = (FileEntry) files.get(i); FileEntry entry = (FileEntry) files.get(i);
if (entry.isDirectory()) try { if (entry.isDirectory()) {
theFileEntry = getFile( try {
((DirectoryEntry)entry).getFiles(), filename); theFileEntry = getFile(
if (theFileEntry != null) break; ((DirectoryEntry)entry).getFiles(), filename);
} catch (DiskException e) { if (theFileEntry != null) break;
// FIXME how to warn the User about this? } catch (DiskException e) {
} // FIXME how to warn the User about this?
}
}
String otherFilename = entry.getFilename(); String otherFilename = entry.getFilename();
if (otherFilename != null) otherFilename = otherFilename.trim(); if (otherFilename != null) otherFilename = otherFilename.trim();
if (filename.equalsIgnoreCase(otherFilename)) { if (filename.equalsIgnoreCase(otherFilename)) {

View File

@ -330,11 +330,13 @@ public class ac {
directory = "."+File.separator; directory = "."+File.separator;
} }
FormattedDisk[] formattedDisks = disk.getFormattedDisks(); FormattedDisk[] formattedDisks = disk.getFormattedDisks();
for (int i = 0; i < formattedDisks.length; i++) try { for (int i = 0; i < formattedDisks.length; i++) {
FormattedDisk formattedDisk = formattedDisks[i]; try {
writeFiles(formattedDisk.getFiles(), directory); FormattedDisk formattedDisk = formattedDisks[i];
} catch (DiskException e) { writeFiles(formattedDisk.getFiles(), directory);
// FIXME How to warn user about the problem? } catch (DiskException e) {
// FIXME How to warn user about the problem?
}
} }
} }
@ -357,10 +359,12 @@ public class ac {
OutputStream output = new FileOutputStream(file); OutputStream output = new FileOutputStream(file);
output.write(buf, 0, buf.length); output.write(buf, 0, buf.length);
output.close(); output.close();
} else if (entry.isDirectory()) try { } else if (entry.isDirectory()) {
writeFiles(((DirectoryEntry) entry).getFiles(),directory+entry.getFilename()+File.separator); try {
} catch (DiskException e) { writeFiles(((DirectoryEntry) entry).getFiles(),directory+entry.getFilename()+File.separator);
// FIXME How to warn user about the problem? } catch (DiskException e) {
// FIXME How to warn user about the problem?
}
} }
} }
} }
@ -441,11 +445,13 @@ public class ac {
} }
System.out.println(); System.out.println();
} }
if (entry.isDirectory()) try { if (entry.isDirectory()) {
showFiles(((DirectoryEntry) entry).getFiles(), try {
indent + " ", display); //$NON-NLS-1$ showFiles(((DirectoryEntry) entry).getFiles(),
} catch (DiskException e) { indent + " ", display); //$NON-NLS-1$
// FIXME How to warn user about the problem? } catch (DiskException e) {
// FIXME How to warn user about the problem?
}
} }
} }
} }

View File

@ -258,20 +258,22 @@ public class DiskExplorerTab {
diskItem.setData(disks[i]); diskItem.setData(disks[i]);
directoryTree.setSelection(new TreeItem[] { diskItem }); directoryTree.setSelection(new TreeItem[] { diskItem });
if (disks[i].canHaveDirectories()) try { if (disks[i].canHaveDirectories()) {
Iterator files = disks[i].getFiles().iterator(); try {
while (files.hasNext()) { Iterator files = disks[i].getFiles().iterator();
FileEntry entry = (FileEntry) files.next(); while (files.hasNext()) {
if (entry.isDirectory()) { FileEntry entry = (FileEntry) files.next();
TreeItem item = new TreeItem(diskItem, SWT.BORDER); if (entry.isDirectory()) {
item.setText(entry.getFilename()); TreeItem item = new TreeItem(diskItem, SWT.BORDER);
item.setData(entry); item.setText(entry.getFilename());
addDirectoriesToTree(item, (DirectoryEntry)entry); item.setData(entry);
addDirectoriesToTree(item, (DirectoryEntry)entry);
}
} }
} } catch (DiskException e) {
} catch (DiskException e) { // FIXME how to warn the User about this?
// FIXME how to warn the User about this? }
} }
} }
computeColumnWidths(FormattedDisk.FILE_DISPLAY_STANDARD); computeColumnWidths(FormattedDisk.FILE_DISPLAY_STANDARD);
@ -1368,11 +1370,13 @@ public class DiskExplorerTab {
viewFileItem.setEnabled(false); viewFileItem.setEnabled(false);
viewFileItem.addSelectionListener(new SelectionAdapter () { viewFileItem.addSelectionListener(new SelectionAdapter () {
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
if (event.detail != SWT.ARROW) try { if (event.detail != SWT.ARROW) {
viewFile(null); try {
} catch (DiskException e) { viewFile(null);
// FIXME how to warn the User about this? } catch (DiskException e) {
} // FIXME how to warn the User about this?
}
}
} }
}); });
printToolItem = new ToolItem(toolBar, SWT.PUSH); printToolItem = new ToolItem(toolBar, SWT.PUSH);
@ -1682,40 +1686,43 @@ public class DiskExplorerTab {
saveAs(); saveAs();
break; break;
} }
} else try { } else {
switch (event.character) { try {
case CTRL_I: // Import Wizard switch (event.character) {
importFiles(); case CTRL_I: // Import Wizard
break; importFiles();
case CTRL_P: // Print... break;
print(); case CTRL_P: // Print...
break; print();
case CTRL_S: // Save break;
if (getSaveToolItem().isEnabled()) { case CTRL_S: // Save
save(); if (getSaveToolItem().isEnabled()) {
} save();
break; }
} break;
} catch (DiskException e) { }
// FIXME how to warn the User about this? } catch (DiskException e) {
} // FIXME how to warn the User about this?
}
}
} else { // No CTRL key } else { // No CTRL key
if ((event.stateMask & SWT.ALT) != SWT.ALT) // Ignore ALT key combinations like alt-F4! if ((event.stateMask & SWT.ALT) != SWT.ALT) // Ignore ALT key combinations like alt-F4!
try { switch (event.keyCode) { try {
case SWT.F2: // Standard file display switch (event.keyCode) {
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_STANDARD); case SWT.F2: // Standard file display
break; changeCurrentFormat(FormattedDisk.FILE_DISPLAY_STANDARD);
case SWT.F3: // Native file display break;
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_NATIVE); case SWT.F3: // Native file display
break; changeCurrentFormat(FormattedDisk.FILE_DISPLAY_NATIVE);
case SWT.F4: // Detail file display break;
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_DETAIL); case SWT.F4: // Detail file display
break; changeCurrentFormat(FormattedDisk.FILE_DISPLAY_DETAIL);
case SWT.F5: // Show deleted files break;
setShowDeletedFiles(!getShowDeletedFilesToolItem().getSelection()); case SWT.F5: // Show deleted files
getShowDeletedFilesToolItem().setSelection(isShowDeletedFiles()); setShowDeletedFiles(!getShowDeletedFilesToolItem().getSelection());
fillFileTable(getCurrentFileList()); getShowDeletedFilesToolItem().setSelection(isShowDeletedFiles());
break; fillFileTable(getCurrentFileList());
break;
} }
} catch (DiskException e) { } catch (DiskException e) {
// FIXME how to warn the User about this? // FIXME how to warn the User about this?