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

View File

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

View File

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