SashControl.createHorizontalSash(50, 50, this, dir_list, shared_files);
GridLayout layout;
dir_list.setLayout(new FillLayout());
dir_list_content = new Group(dir_list,SWT.NONE);
java.util.List<File> dir = null;
try {
dir = _core.getConfigurationManager().getSharedFolders();
} catch (ConfigurationManagerException e) {
e.printStackTrace();
}
if (dir != null)
dir_list_content.setText(_._("mainwindow.sharedtab.group.shared_dirs")+"("+dir.size()+")");
else
dir_list_content.setText(_._("mainwindow.sharedtab.group.shared_dirs")+"(0)");
config_listener = new ConfigurationAdapter() {
public void sharedDirectoriesChanged(java.util.List<File> sharedDirs) {
dir_list_content.setText(_._("mainwindow.sharedtab.group.shared_dirs")+"("+sharedDirs.size()+")");
}
};
layout = new GridLayout(1,false);
layout.marginWidth = 2;
layout.marginHeight = 2;
dir_list_content.setLayout(layout);
Composite control_block = new Composite(dir_list_content,SWT.NONE);
layout = new GridLayout(4,false);
layout.marginHeight = 0;
layout.marginWidth = 0;
control_block.setLayout(layout);
GridData data = new GridData();
data.widthHint = 400;
control_block.setLayoutData(data);
Button add_button = new Button(control_block,SWT.NONE);
add_button.setFont(skin.getButtonFont());
add_button.setImage(SWTImageRepository.getImage("add.png"));
add_button.setText(_._("mainwindow.sharedtab.button.add"));
add_button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
add_button.setAlignment(SWT.LEFT);
add_button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dir_dialog = new DirectoryDialog (getShell(),SWT.MULTI | SWT.OPEN);
String directory = dir_dialog.open();
if (directory == null) return ;
java.util.List<File> shared_dirs = null;
try {
shared_dirs = config_manager.getSharedFolders();
} catch (ConfigurationManagerException e) {
e.printStackTrace();
}
java.util.List<File> newDirs = new LinkedList<File>();
if (shared_dirs == null)
shared_dirs = new CopyOnWriteArrayList<File>();
else
shared_dirs = new CopyOnWriteArrayList<File>(shared_dirs);
java.util.List<File> already_exist_list = org.jmule.core.utils.FileUtils.extractNewFolders(new File[]{new File(directory)},shared_dirs,newDirs);
if (already_exist_list.size()!=0) {
AlreadyExistDirsWindow window = new AlreadyExistDirsWindow(already_exist_list);
window.getCoreComponents();
window.initUIComponents();
}
shared_dirs.addAll(newDirs);
try {
config_manager.setSharedFolders(shared_dirs);
} catch (ConfigurationManagerException e) {
e.printStackTrace();
}
} });
remove_button = new Button(control_block,SWT.NONE);
remove_button.setFont(skin.getButtonFont());
remove_button.setText(_._("mainwindow.sharedtab.button.remove"));
remove_button.setImage(SWTImageRepository.getImage("remove.png"));
remove_button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
remove_button.setAlignment(SWT.LEFT);
remove_button.setEnabled(false);
remove_button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
removeSelectedDir();
} });
clear_button = new Button(control_block,SWT.NONE);
clear_button.setFont(skin.getButtonFont());
clear_button.setText(_._("mainwindow.sharedtab.button.clear"));
clear_button.setImage(SWTImageRepository.getImage("remove_all.png"));
clear_button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
clear_button.setAlignment(SWT.LEFT);
clear_button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
clearDirList();
} });
Button reload_button = new Button(control_block,SWT.NONE);
reload_button.setFont(skin.getButtonFont());
reload_button.setText(_._("mainwindow.sharedtab.button.reload"));
reload_button.setImage(SWTImageRepository.getImage("refresh.png"));
reload_button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
sharing_manager.loadCompletedFiles();
}
});
shared_dir_list = new List (dir_list_content, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
shared_dir_list.setLayoutData(new GridData(GridData.FILL_BOTH));
shared_dir_list.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String selected_dir = shared_dir_list.getSelection()[0];
if (selected_dir.equals(last_selection)) return ;
last_selection = selected_dir;
updateFileList(selected_dir);
int selection_id = shared_dir_list.getSelectionIndex();
if ((selection_id>=no_remove_id_start)&&(selection_id<=no_remove_id_end)) {
remove_button.setEnabled(false);
return;
}
remove_button.setEnabled(true);
}
});
shared_files.setLayout(new FillLayout());
shared_files_group = new Group(shared_files,SWT.NONE);
shared_files_group.setText(_._("mainwindow.sharedtab.group.shared_files"));
shared_files_group.setLayout(new FillLayout());
shared_files_table = new JMTable<SharedFile>(shared_files_group, SWT.NONE){
protected int compareObjects(SharedFile object1, SharedFile object2,
int columnID, boolean order) {
if (columnID == SWTConstants.SHARED_LIST_FILE_NAME_COLUMN_ID) {
return Misc.compareAllObjects(object1, object2, "getSharingName", order);