📄 filesview.java
字号:
{
String s_target = askForRenameFilename(fileInfo);
if (s_target != null)
f_target = new File(existing_file.getParentFile(), s_target);
} else
{
f_target = new File(save_dir, existing_file.getName());
}
if (f_target == null)
{
if (paused)
manager.resume();
return;
}
if (!paused)
paused = manager.pause();
if (!f_target.exists() || !f_target.equals(existing_file) && (!existing_file.exists() || askCanOverwrite(existing_file)))
{
moveFile(fileInfo, f_target);
row.invalidate();
}
i++;
goto _L1
if (paused)
manager.resume();
break MISSING_BLOCK_LABEL_317;
Exception exception;
exception;
if (paused)
manager.resume();
throw exception;
}
private void changePriority(int type, TableRowCore rows[])
{
boolean paused;
if (manager == null)
return;
paused = false;
DiskManagerFileInfo file_infos[] = new DiskManagerFileInfo[rows.length];
for (int i = 0; i < rows.length; i++)
{
file_infos[i] = (DiskManagerFileInfo)rows[i].getDataSource(true);
if (type == 0 || type == 1)
file_infos[i].setPriority(type == 0);
}
boolean skipped = type == 2 || type == 3;
boolean delete_action = type == 3;
paused = setSkipped(file_infos, skipped, delete_action);
if (paused)
manager.resume();
break MISSING_BLOCK_LABEL_153;
Exception exception;
exception;
if (paused)
manager.resume();
throw exception;
}
private boolean setSkipped(DiskManagerFileInfo infos[], boolean skipped, boolean delete_action)
{
if (!manager.isPersistent())
{
for (int i = 0; i < infos.length; i++)
infos[i].setSkipped(skipped);
return false;
}
int existing_storage_types[] = manager.getStorageType(infos);
int nbFiles = manager.getDiskManagerFileInfoSet().nbFiles();
boolean setLinear[] = new boolean[nbFiles];
boolean setCompact[] = new boolean[nbFiles];
int compactCount = 0;
int linearCount = 0;
if (infos.length <= 1);
File save_location = manager.getAbsoluteSaveLocation();
boolean root_exists = save_location.isDirectory() || infos.length <= 1 && save_location.exists();
boolean type_has_been_changed = false;
boolean requires_pausing = false;
for (int i = 0; i < infos.length; i++)
{
int existing_storage_type = existing_storage_types[i];
int new_storage_type = 1;
if (skipped)
{
File existing_file = infos[i].getFile(true);
boolean perform_check;
if (root_exists)
perform_check = true;
else
if (FileUtil.isAncestorOf(save_location, existing_file))
perform_check = false;
else
perform_check = true;
if (perform_check && existing_file.exists())
{
if (delete_action)
{
boolean wants_to_delete = MessageBoxWindow.open("FilesView.messagebox.delete.id", 288, 32, true, Display.getDefault(), "warning", MessageText.getString("FilesView.rename.confirm.delete.title"), MessageText.getString("FilesView.rename.confirm.delete.text", new String[] {
existing_file.toString()
})) == 32;
if (wants_to_delete)
new_storage_type = 2;
}
} else
{
new_storage_type = 2;
}
}
boolean has_changed = existing_storage_type != new_storage_type;
type_has_been_changed |= has_changed;
requires_pausing |= has_changed && new_storage_type == 2;
type_has_been_changed = existing_storage_type != new_storage_type;
if (new_storage_type == 2)
{
setCompact[infos[i].getIndex()] = true;
compactCount++;
} else
{
setLinear[infos[i].getIndex()] = true;
linearCount++;
}
}
boolean ok = true;
boolean paused = false;
if (type_has_been_changed)
{
if (requires_pausing)
paused = manager.pause();
if (linearCount > 0)
ok &= Arrays.equals(setLinear, manager.getDiskManagerFileInfoSet().setStorageTypes(setLinear, 1));
if (compactCount > 0)
ok &= Arrays.equals(setCompact, manager.getDiskManagerFileInfoSet().setStorageTypes(setCompact, 2));
}
if (ok)
{
for (int i = 0; i < infos.length; i++)
infos[i].setSkipped(skipped);
}
return paused;
}
public void tableRefresh()
{
if (refreshing)
return;
refreshing = true;
if (tv.isDisposed())
{
refreshing = false;
return;
}
DiskManagerFileInfo files[] = getFileInfo();
if (files != null && (force_refresh || !doAllExist(files)))
{
force_refresh = false;
List datasources = tv.getDataSources();
if (datasources.size() == files.length)
{
ArrayList toAdd = new ArrayList(Arrays.asList(files));
ArrayList toRemove = new ArrayList();
for (int i = 0; i < datasources.size(); i++)
{
DiskManagerFileInfo info = (DiskManagerFileInfo)datasources.get(i);
if (files[info.getIndex()] == info)
toAdd.set(info.getIndex(), null);
else
toRemove.add(info);
}
tv.removeDataSources(toRemove.toArray());
tv.addDataSources(toAdd.toArray());
((TableViewSWTImpl)tv).tableInvalidate();
} else
{
tv.removeAllTableRows();
Object filesCopy[] = new Object[files.length];
System.arraycopy(files, 0, ((Object) (filesCopy)), 0, files.length);
tv.addDataSources(filesCopy);
}
tv.processDataSourceQueue();
}
refreshing = false;
break MISSING_BLOCK_LABEL_274;
Exception exception;
exception;
refreshing = false;
throw exception;
}
private boolean doAllExist(DiskManagerFileInfo files[])
{
for (int i = 0; i < files.length; i++)
{
DiskManagerFileInfo fileinfo = files[i];
TableRowCore row = tv.getRow(fileinfo);
if (row == null)
return false;
if (row.getDataSource(true) != fileinfo)
return false;
}
return true;
}
public void addThisColumnSubMenu(String sColumnName, Menu menuThisColumn)
{
if (sColumnName.equals("path"))
{
path_item = new MenuItem(menuThisColumn, 32);
menuThisColumn.addListener(22, new Listener() {
final FilesView this$0;
public void handleEvent(Event e)
{
path_item.setSelection(FilesView.show_full_path);
}
{
this$0 = FilesView.this;
super();
}
});
Messages.setLanguageText(path_item, "FilesView.fullpath");
path_item.addListener(13, new Listener() {
final FilesView this$0;
public void handleEvent(Event e)
{
FilesView.show_full_path = path_item.getSelection();
tv.columnInvalidate("path");
tv.refreshTable(false);
COConfigurationManager.setParameter("FilesView.show.full.path", FilesView.show_full_path);
}
{
this$0 = FilesView.this;
super();
}
});
}
}
private DiskManagerFileInfo[] getFileInfo()
{
if (manager == null)
return null;
else
return manager.getDiskManagerFileInfo();
}
public void attributeEventOccurred(DownloadManager dm, String attribute_name, int event_type)
{
if (is_changing_links)
{
return;
} else
{
force_refresh = true;
return;
}
}
public void tableViewInitialized()
{
createDragDrop();
}
public void tableViewDestroyed()
{
Utils.execSWTThread(new AERunnable() {
final FilesView this$0;
public void runSupport()
{
try
{
Utils.disposeSWTObjects(new Object[] {
dragSource
});
dragSource = null;
}
catch (Exception e)
{
Debug.out(e);
}
}
{
this$0 = FilesView.this;
super();
}
});
if (manager != null)
manager.getDownloadState().removeListener(this, "filelinks", 1);
}
public void mouseEnter(TableRowCore tablerowcore)
{
}
public void mouseExit(TableRowCore tablerowcore)
{
}
private void createDragDrop()
{
try
{
Transfer types[] = {
TextTransfer.getInstance()
};
if (dragSource != null && !dragSource.isDisposed())
dragSource.dispose();
dragSource = tv.createDragSource(3);
if (dragSource != null)
{
dragSource.setTransfer(types);
dragSource.addDragListener(new DragSourceAdapter() {
private String eventData;
final FilesView this$0;
public void dragStart(DragSourceEvent event)
{
Object selectedDownloads[];
TOTorrent torrent;
int i;
TableRowCore rows[] = tv.getSelectedRows();
if (rows.length != 0 && manager != null && manager.getTorrent() != null)
{
event.doit = true;
} else
{
event.doit = false;
return;
}
selectedDownloads = tv.getSelectedDataSources().toArray();
eventData = "DiskManagerFileInfo\n";
torrent = manager.getTorrent();
i = 0;
_L3:
if (i >= selectedDownloads.length) goto _L2; else goto _L1
_L1:
DiskManagerFileInfo fi = (DiskManagerFileInfo)selectedDownloads[i];
new StringBuilder();
this;
JVM INSTR dup_x1 ;
eventData;
append();
torrent.getHashWrapper().toBase32String();
append();
";";
append();
fi.getIndex();
append();
"\n";
append();
toString();
eventData;
continue; /* Loop/switch isn't completed */
Exception e;
e;
i++;
goto _L3
_L2:
}
public void dragSetData(DragSourceEvent event)
{
event.data = eventData;
}
{
this$0 = FilesView.this;
super();
}
});
}
}
catch (Throwable t)
{
Logger.log(new LogEvent(LogIDs.GUI, "failed to init drag-n-drop", t));
}
}
static
{
COConfigurationManager.addAndFireParameterListener("FilesView.show.full.path", new ParameterListener() {
public void parameterChanged(String parameterName)
{
FilesView.show_full_path = COConfigurationManager.getBooleanParameter("FilesView.show.full.path");
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -