public ImportOrganizeConfigurationBlock( IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) { super(context, project, getAllKeys(), container); String[] buttonLabels = new String[] { PreferencesMessages.ImportOrganizeConfigurationBlock_order_add_button, PreferencesMessages.ImportOrganizeConfigurationBlock_order_add_static_button, PreferencesMessages.ImportOrganizeConfigurationBlock_order_edit_button, PreferencesMessages.ImportOrganizeConfigurationBlock_order_remove_button, /* 4 */ null, PreferencesMessages.ImportOrganizeConfigurationBlock_order_up_button, PreferencesMessages.ImportOrganizeConfigurationBlock_order_down_button, }; ImportOrganizeAdapter adapter = new ImportOrganizeAdapter(); fOrderListField = new ListDialogField(adapter, buttonLabels, new ImportOrganizeLabelProvider()); fOrderListField.setDialogFieldListener(adapter); fOrderListField.setLabelText(PreferencesMessages.ImportOrganizeConfigurationBlock_order_label); fOrderListField.setUpButtonIndex(IDX_UP); fOrderListField.setDownButtonIndex(IDX_DOWN); fOrderListField.setRemoveButtonIndex(IDX_REMOVE); fOrderListField.enableButton(IDX_EDIT, false); fImportButton = new SelectionButtonDialogField(SWT.PUSH); fImportButton.setDialogFieldListener(adapter); fImportButton.setLabelText( PreferencesMessages.ImportOrganizeConfigurationBlock_order_load_button); fExportButton = new SelectionButtonDialogField(SWT.PUSH); fExportButton.setDialogFieldListener(adapter); fExportButton.setLabelText( PreferencesMessages.ImportOrganizeConfigurationBlock_order_save_button); fThresholdField = new StringDialogField(); fThresholdField.setDialogFieldListener(adapter); fThresholdField.setLabelText( PreferencesMessages.ImportOrganizeConfigurationBlock_threshold_label); fStaticThresholdField = new StringDialogField(); fStaticThresholdField.setDialogFieldListener(adapter); fStaticThresholdField.setLabelText( PreferencesMessages.ImportOrganizeConfigurationBlock_staticthreshold_label); fIgnoreLowerCaseTypesField = new SelectionButtonDialogField(SWT.CHECK); fIgnoreLowerCaseTypesField.setDialogFieldListener(adapter); fIgnoreLowerCaseTypesField.setLabelText( PreferencesMessages.ImportOrganizeConfigurationBlock_ignoreLowerCase_label); updateControls(); }
/* (non-Javadoc) * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls() */ protected void updateControls() { ImportOrderEntry[] importOrder = getImportOrderPreference(); int threshold = getImportNumberThreshold(PREF_ONDEMANDTHRESHOLD); int staticThreshold = getImportNumberThreshold(PREF_STATICONDEMANDTHRESHOLD); boolean ignoreLowerCase = Boolean.valueOf(getValue(PREF_IGNORELOWERCASE)).booleanValue(); fOrderListField.removeAllElements(); for (int i = 0; i < importOrder.length; i++) { fOrderListField.addElement(importOrder[i]); } fThresholdField.setText(String.valueOf(threshold)); fStaticThresholdField.setText(String.valueOf(staticThreshold)); fIgnoreLowerCaseTypesField.setSelection(ignoreLowerCase); }
protected Control createContents(Composite parent) { setShell(parent.getShell()); fPixelConverter = new PixelConverter(parent); Composite composite = new Composite(parent, SWT.NONE); composite.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout(layout); fOrderListField.doFillIntoGrid(composite, 3); LayoutUtil.setHorizontalSpan(fOrderListField.getLabelControl(null), 2); LayoutUtil.setWidthHint( fOrderListField.getLabelControl(null), fPixelConverter.convertWidthInCharsToPixels(60)); LayoutUtil.setHorizontalGrabbing(fOrderListField.getListControl(null)); Composite importExportComp = new Composite(composite, SWT.NONE); importExportComp.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1)); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; importExportComp.setLayout(layout); fImportButton.doFillIntoGrid(importExportComp, 1); fExportButton.doFillIntoGrid(importExportComp, 1); fThresholdField.doFillIntoGrid(composite, 2); ((GridData) fThresholdField.getTextControl(null).getLayoutData()).grabExcessHorizontalSpace = false; fStaticThresholdField.doFillIntoGrid(composite, 2); fIgnoreLowerCaseTypesField.doFillIntoGrid(composite, 2); Dialog.applyDialogFont(composite); return composite; }
protected final void doDialogFieldChanged(DialogField field) { // set values in working copy if (field == fOrderListField) { setValue(PREF_IMPORTORDER, packOrderList(fOrderListField.getElements())); } else if (field == fThresholdField) { if (doThresholdChanged(fThresholdField.getText())) { setValue(PREF_ONDEMANDTHRESHOLD, fThresholdField.getText()); } } else if (field == fStaticThresholdField) { if (doThresholdChanged(fStaticThresholdField.getText())) { setValue(PREF_STATICONDEMANDTHRESHOLD, fStaticThresholdField.getText()); } } else if (field == fIgnoreLowerCaseTypesField) { setValue(PREF_IGNORELOWERCASE, fIgnoreLowerCaseTypesField.isSelected()); } else if (field == fImportButton) { List order = loadImportOrder(); if (order != null) { fOrderListField.setElements(order); } } else if (field == fExportButton) { saveImportOrder(fOrderListField.getElements()); } }