1 11 12 package org.eclipse.jdt.apt.ui.internal.preferences; 13 14 import java.io.IOException ; 15 import java.util.Map.Entry; 16 17 import org.eclipse.jdt.apt.core.internal.util.FactoryContainer; 18 import org.eclipse.jdt.apt.core.internal.util.FactoryPath; 19 import org.eclipse.jdt.apt.ui.internal.util.ExceptionHandler; 20 import org.eclipse.jdt.apt.ui.internal.util.IAptHelpContextIds; 21 import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; 22 import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; 23 import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; 24 import org.eclipse.jface.dialogs.Dialog; 25 import org.eclipse.jface.viewers.ListViewer; 26 import org.eclipse.swt.SWT; 27 import org.eclipse.swt.layout.GridData; 28 import org.eclipse.swt.widgets.Composite; 29 import org.eclipse.swt.widgets.Control; 30 import org.eclipse.swt.widgets.Label; 31 import org.eclipse.swt.widgets.Shell; 32 import org.eclipse.ui.PlatformUI; 33 34 41 public class AdvancedFactoryPathOptionsDialog extends Dialog { 42 43 private final static int LIST_WIDTH= 70; private final static int LIST_HEIGHT= 10; 46 private class FieldAdapter implements IDialogFieldListener { 47 public void dialogFieldChanged(DialogField field) { 48 } 49 } 50 51 private final FactoryContainer _fc; 53 private final FactoryPath.Attributes _attr; 54 55 private SelectionButtonDialogField _batchModeField; 57 private ListViewer _contentsField; 58 59 public AdvancedFactoryPathOptionsDialog( 60 Shell parent, FactoryContainer fc, FactoryPath.Attributes attr) { 61 super(parent); 62 setShellStyle(getShellStyle() | SWT.RESIZE); 63 _fc= fc; 64 _attr= attr; 65 } 66 67 protected void configureShell(Shell shell) { 68 super.configureShell(shell); 69 shell.setText(Messages.AdvancedFactoryPathOptionsDialog_advancedOptions); 70 PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IAptHelpContextIds.ADVANCED_FACTORYPATH_OPTIONS_DIALOG); 71 } 72 73 protected Control createDialogArea(Composite parent) { 74 Composite dlgArea= (Composite) super.createDialogArea(parent); 75 76 FieldAdapter adapter = new FieldAdapter(); 78 _batchModeField = new SelectionButtonDialogField(SWT.CHECK); 79 _batchModeField.setSelection(_attr.runInBatchMode()); 80 _batchModeField.setLabelText(Messages.AdvancedFactoryPathOptionsDialog_batchMode); 81 _batchModeField.setDialogFieldListener(adapter); 82 _batchModeField.doFillIntoGrid(dlgArea, 2); 83 boolean isPlugin = _fc.getType() == FactoryContainer.FactoryType.PLUGIN; 85 _batchModeField.setEnabled(!isPlugin); 86 87 DialogField.createEmptySpace(dlgArea, 1); 88 89 Label description= new Label(dlgArea, SWT.WRAP); 91 description.setText(Messages.AdvancedFactoryPathOptionsDialog_label_processorsInThisContainer); 92 GridData gdLabel= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 93 gdLabel.horizontalSpan= 2; 94 description.setLayoutData(gdLabel); 95 96 _contentsField= new ListViewer(dlgArea, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); 98 GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); 99 data.heightHint = convertHeightInCharsToPixels(LIST_HEIGHT); 100 data.widthHint = convertWidthInCharsToPixels(LIST_WIDTH); 101 _contentsField.getList().setLayoutData(data); 102 _contentsField.getList().setFont(parent.getFont()); 103 try { 104 for (Entry<String , String > entry : _fc.getFactoryNames().entrySet()) { 105 String name = entry.getKey(); 106 _contentsField.add(name); 107 } 109 } 110 catch (IOException e) { 111 final String message = "Unable to load factory names from container [" + _fc.getId() + "]"; ExceptionHandler.log(e, message); 113 } 114 _contentsField.setSelection(null, false); 115 116 applyDialogFont(dlgArea); 117 return dlgArea; 118 } 119 120 126 public FactoryPath.Attributes getResult() { 127 boolean batchMode = _batchModeField.isSelected(); 128 return new FactoryPath.Attributes(_attr.isEnabled(), batchMode); 129 } 130 } 131 | Popular Tags |