private CustomVfsUiPanel getPanelFromFileUri(String fileUri) { if (customUIPanels != null) { for (CustomVfsUiPanel panel : customUIPanels) { if (fileUri.startsWith(panel.getVfsScheme())) { return panel; } } } return null; }
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 createCustomUIPanel(final Shell dialog) { customUIPanel = new Composite(dialog, SWT.NONE); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); customUIPanel.setLayoutData(gridData); customUIPanel.setLayout(new GridLayout(1, false)); comboPanel = new Composite(customUIPanel, SWT.NONE); comboPanel.setLayoutData(gridData); comboPanel.setLayout(new GridLayout(2, false)); comboPanel.setData("donotremove"); Label lookInLabel = new Label(comboPanel, SWT.NONE); lookInLabel.setText(Messages.getString("VfsFileChooserDialog.LookIn")); gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false); lookInLabel.setLayoutData(gridData); customUIPicker = new Combo(comboPanel, SWT.READ_ONLY); gridData = new GridData(SWT.LEFT, SWT.CENTER, true, false); customUIPicker.setLayoutData(gridData); if (!showLocation) { comboPanel.setParent(fakeShell); } if (!showCustomUI) { customUIPanel.setParent(fakeShell); } customUIPicker.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent event) { selectCustomUI(); } public void widgetDefaultSelected(SelectionEvent event) { selectCustomUI(); } }); customUIPicker.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent arg0) { selectCustomUI(); } public void keyPressed(KeyEvent arg0) { selectCustomUI(); } }); boolean createdLocal = false; for (CustomVfsUiPanel panel : customUIPanels) { if (panel.getVfsScheme().equals("file")) { createdLocal = true; } } if (!createdLocal) { CustomVfsUiPanel localPanel = new CustomVfsUiPanel("file", "Local", this, SWT.None) { public void activate() { try { File startFile = new File(System.getProperty("user.home")); if (startFile == null || !startFile.exists()) { startFile = File.listRoots()[0]; } FileObject dot = fsm.resolveFile(startFile.toURI().toURL().toExternalForm()); rootFile = dot.getFileSystem().getRoot(); selectedFile = rootFile; setInitialFile(selectedFile); openFileCombo.setText(selectedFile.getName().getURI()); resolveVfsBrowser(); } catch (Throwable t) { } } }; addVFSUIPanel(localPanel); } }