public void createFileFilterPanel(Shell dialog) { Composite filterPanel = new Composite(dialog, SWT.NONE); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); filterPanel.setLayoutData(gridData); filterPanel.setLayout(new GridLayout(3, false)); // create filter label Label filterLabel = new Label(filterPanel, SWT.NONE); filterLabel.setText(Messages.getString("VfsFileChooserDialog.filter")); // $NON-NLS-1$ gridData = new GridData(SWT.FILL, SWT.CENTER, false, false); filterLabel.setLayoutData(gridData); // create file filter combo fileFilterCombo = new Combo(filterPanel, SWT.READ_ONLY); gridData = new GridData(SWT.FILL, SWT.FILL, true, false); fileFilterCombo.setLayoutData(gridData); fileFilterCombo.setItems(fileFilterNames); fileFilterCombo.addSelectionListener(this); fileFilterCombo.select(0); }
public void populateCustomUIPanel(Shell dialog) { ArrayList<String> customNames = new ArrayList<String>(); for (int i = 0; i < customUIPanels.size(); i++) { CustomVfsUiPanel panel = customUIPanels.get(i); if (panel.getVfsScheme().equalsIgnoreCase("file") || schemeRestrictions == null || isRestrictedTo(panel.getVfsScheme())) { if (panel.getVfsScheme().equalsIgnoreCase("file") && !showFileScheme) { continue; } customNames.add(panel.getVfsSchemeDisplayText()); } } customUIPicker.setItems(customNames.toArray(new String[] {})); hideCustomPanelChildren(); // hide entire panel if no customizations if (customNames.size() == 0) { customUIPanel.setParent(fakeShell); } else { if (customNames.size() == 1 && "file".equals(customNames.get(0))) { customUIPanel.setParent(fakeShell); } else { String initialSchemeDisplayText = initialScheme; for (int i = 0; i < customUIPanels.size(); i++) { if (customUIPanels.get(i).getVfsScheme().equalsIgnoreCase(initialScheme)) { initialSchemeDisplayText = customUIPanels.get(i).getVfsSchemeDisplayText(); break; } } for (int i = 0; i < customUIPicker.getItemCount(); i++) { if (customUIPicker.getItem(i).equalsIgnoreCase(initialSchemeDisplayText)) { customUIPicker.select(i); customUIPicker.notifyListeners(SWT.Selection, null); } } } } }
public void updateParentFileCombo(FileObject selectedItem) { try { List<FileObject> parentChain = new ArrayList<FileObject>(); // are we a directory? try { if (selectedItem.getType() == FileType.FOLDER && selectedItem.getType().hasChildren()) { // we have real children.... parentChain.add(selectedItem); } } catch (Exception e) { // we are not a folder } FileObject parentFileObject; parentFileObject = selectedItem.getParent(); while (parentFileObject != null) { parentChain.add(parentFileObject); parentFileObject = parentFileObject.getParent(); } File roots[] = File.listRoots(); if (currentPanel != null) { for (int i = 0; i < roots.length; i++) { parentChain.add(currentPanel.resolveFile(roots[i].getAbsolutePath())); } } String items[] = new String[parentChain.size()]; int idx = 0; for (int i = parentChain.size() - 1; i >= 0; i--) { items[idx++] = ((FileObject) parentChain.get(i)).getName().getURI(); } openFileCombo.setItems(items); openFileCombo.select(items.length - 1); } catch (Exception e) { e.printStackTrace(); // then let's not update the GUI } }