1 11 package org.eclipse.pde.internal.ui.wizards.exports; 12 13 import org.eclipse.jface.dialogs.IDialogSettings; 14 import org.eclipse.pde.internal.ui.PDEPlugin; 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.widgets.Combo; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.swt.widgets.FileDialog; 20 21 public abstract class AbstractExportTab { 22 23 protected AbstractExportWizardPage fPage; 24 25 public AbstractExportTab(AbstractExportWizardPage page) { 26 fPage = page; 27 } 28 29 protected abstract Control createControl(Composite parent); 30 31 protected abstract void initialize(IDialogSettings settings); 32 33 protected abstract void saveSettings(IDialogSettings settings); 34 35 protected void initializeCombo(IDialogSettings settings, String key, Combo combo) { 36 for (int i = 0; i < 6; i++) { 37 String curr = settings.get(key + String.valueOf(i)); 38 if (curr != null && combo.indexOf(curr) == -1) { 39 combo.add(curr); 40 } 41 } 42 if (combo.getItemCount() > 0) 43 combo.setText(combo.getItem(0)); 44 } 45 46 protected void saveCombo(IDialogSettings settings, String key, Combo combo) { 47 if (combo.getText().trim().length() > 0) { 48 settings.put(key + String.valueOf(0), combo.getText().trim()); 49 String [] items = combo.getItems(); 50 int nEntries = Math.min(items.length, 5); 51 for (int i = 0; i < nEntries; i++) { 52 settings.put(key + String.valueOf(i + 1), items[i].trim()); 53 } 54 } 55 } 56 57 protected void chooseFile(Combo combo, String filter) { 58 FileDialog dialog = new FileDialog(fPage.getShell(), SWT.SAVE); 59 String path = combo.getText(); 60 if (path.trim().length() == 0) 61 path = PDEPlugin.getWorkspace().getRoot().getLocation().toString(); 62 dialog.setFileName(path); 63 dialog.setFilterExtensions(new String [] { filter }); 64 String res = dialog.open(); 65 if (res != null) { 66 if (combo.indexOf(res) == -1) 67 combo.add(res, 0); 68 combo.setText(res); 69 } 70 } 71 72 73 } 74 | Popular Tags |