fix behavior of FileBrowserDialog

This commit is contained in:
Eyck Jentzsch 2020-03-30 11:31:51 +02:00
parent 8011585113
commit 414030cbd2
3 changed files with 14 additions and 15 deletions

View File

@ -31,7 +31,7 @@ public class OpenHandler {
@Execute
public void execute(Shell shell, MApplication app, EModelService modelService, EPartService partService){
FileBrowserDialog dlg = new FileBrowserDialog(shell);
dlg.create();
//dlg.create();
dlg.setFilterExtensions (new String []{Messages.OpenHandler_0, "*"});
if (dlg.open() != Window.OK) return;
List<File> files = dlg.getSelectedFiles();

View File

@ -45,7 +45,7 @@ WaveformViewer_18=Would you like to reload the database?
WaveformViewer_19=vcd
WaveformViewer_20=txdb
WaveformViewer_21=txlog
WaveformViewer_22=txldb
WaveformViewer_22=fbrdb
WaveformViewer_37=Database open
WaveformViewer_38=Would you like to open the adjacent database
WaveformViewer_39=\ as well?

View File

@ -92,8 +92,11 @@ public class FileBrowserDialog extends TrayDialog {
} else {
globber= new FileGlobber(filterStrings[0]);
imageGlobber = new FileGlobber(filterStrings[0]);
if(filterCombo!=null) {
filterCombo.setItems(filterStrings);
filterCombo.select(0);
filterCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT);
}
}
this.filterStrings=filterStrings;
}
@ -102,20 +105,14 @@ public class FileBrowserDialog extends TrayDialog {
return selectedFiles;
}
@Override
public int open() {
dirTreeViewer.setInput("root");
dirTreeViewer.refresh();
setDirSelection(currentDirFile.getAbsoluteFile().getParentFile());
getButton(IDialogConstants.OK_ID).setEnabled(!tableViewer.getSelection().isEmpty());
return super.open();
}
@Override
protected Control createContents(Composite parent) {
Control ret = super.createContents(parent);
setDirSelection(currentDirFile.getAbsoluteFile().getParentFile());
getButton(IDialogConstants.OK_ID).setEnabled(!tableViewer.getSelection().isEmpty());
if(parent instanceof Shell) {
((Shell)parent).setSize(800, 400);
Point size = ((Shell)parent).computeSize(SWT.DEFAULT, SWT.DEFAULT);
((Shell)parent).setSize(size.x, 400);
((Shell)parent).setText("Select database");
}
return ret;
@ -138,6 +135,7 @@ public class FileBrowserDialog extends TrayDialog {
tableViewer.setInput(selectedDir.listFiles());
}
});
dirTreeViewer.setInput("root");
final Composite tableViewerParent = new Composite(sashForm, SWT.NONE);
GridLayout gridLayout = new GridLayout(1, true);
@ -252,6 +250,7 @@ public class FileBrowserDialog extends TrayDialog {
fileNameEntry = new Text(bottomBar, SWT.BORDER);
fileNameEntry.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
fileNameEntry.setEditable(false); //TODO: temporary disabled
fileNameEntry.setEnabled(false);
filterCombo = new Combo(bottomBar, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
filterCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
@ -264,7 +263,7 @@ public class FileBrowserDialog extends TrayDialog {
tableViewer.setInput(selectedDir.listFiles());
}
});
sashForm.setWeights(new int[]{2, 3});
sashForm.setWeights(new int[]{3, 3});
return area;
}
@ -285,7 +284,7 @@ public class FileBrowserDialog extends TrayDialog {
private void setDirSelection(File f) {
ArrayList<File> fileTree = getParentDirList(f);
TreeSelection selection = new TreeSelection(new TreePath(fileTree.toArray()));
dirTreeViewer.setSelection(selection);
dirTreeViewer.setSelection(selection, true);
}
private ArrayList<File> getParentDirList(File actual){