protected void forceSplitChanged(boolean forceSplit) { Iterator<Category> iterator= fSelectionState.fElements.iterator(); String currentKey; while (iterator.hasNext()) { currentKey= iterator.next().key; try { changeForceSplit(currentKey, forceSplit); } catch (IllegalArgumentException e) { fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(forceSplit, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e)); } } fSelectionState.refreshState(fSelection); }
protected void indentStyleChanged(int indentStyle) { Iterator iterator= fSelectionState.fElements.iterator(); String currentKey; while (iterator.hasNext()) { currentKey= ((Category)iterator.next()).key; try { changeIndentStyle(currentKey, indentStyle); } catch (IllegalArgumentException e) { fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, indentStyle)); JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e)); } } fSelectionState.refreshState(fSelection); }
protected void wrappingStyleChanged(int wrappingStyle) { Iterator iterator= fSelectionState.fElements.iterator(); String currentKey; while (iterator.hasNext()) { currentKey= ((Category)iterator.next()).key; try { changeWrappingStyle(currentKey, wrappingStyle); } catch (IllegalArgumentException e) { fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, wrappingStyle, DefaultCodeFormatterConstants.INDENT_DEFAULT)); JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e)); } } fSelectionState.refreshState(fSelection); }
final Group lineWidthGroup= createGroup(numColumns, composite, FormatterMessages.LineWrappingTabPage_width_indent); createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_max_line_width, DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, 0, 9999); createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_wrapped, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, 0, 9999); createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_array, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, 0, 9999); final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT); gd.heightHint= fPixelConverter.convertHeightInCharsToPixels(5); fCategoriesViewer.getControl().setLayoutData(gd); fOptionsGroup = createGroup(numColumns, composite, ""); //$NON-NLS-1$ fWrappingStylePolicy= createLabel(numColumns, fOptionsGroup, FormatterMessages.LineWrappingTabPage_wrapping_policy_label_text); fWrappingStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0)); fIndentStylePolicy= createLabel(numColumns, fOptionsGroup, FormatterMessages.LineWrappingTabPage_indentation_policy_label_text); fIndentStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0)); fForceSplit.setLayoutData(createGridData(numColumns - 1, GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.DEFAULT)); fForceSplit.setText(FormatterMessages.LineWrappingTabPage_force_split_checkbox_text); Preference expressionWrapPositionPreference= createCheckboxPref(fOptionsGroup, 1, FormatterMessages.LineWrappingTabPage_binary_expression_wrap_operator, DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_BINARY_OPERATOR, FALSE_TRUE); Control control= expressionWrapPositionPreference.getControl(); control.setVisible(false);
protected void addPages(Map values) { addTabPage(FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_blank_lines_title, new BlankLinesTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_new_lines_title, new NewLinesTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_control_statements_title, new ControlStatementsTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_line_wrapping_title, new LineWrappingTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_comments_title, new CommentsTabPage(this, values)); }
/** * Create a new line wrapping tab page. * @param modifyDialog * @param workingValues */ public LineWrappingTabPage(ModifyDialog modifyDialog, Map workingValues) { super(modifyDialog, workingValues); fDialogSettings= JavaPlugin.getDefault().getDialogSettings(); final String previewLineWidth= fDialogSettings.get(PREF_PREVIEW_LINE_WIDTH); fPreviewPreferences= new HashMap(); fPreviewPreferences.put(LINE_SPLIT, previewLineWidth != null ? previewLineWidth : Integer.toString(DEFAULT_PREVIEW_WINDOW_LINE_WIDTH)); fCategories= createCategories(); fCategoryListener= new CategoryListener(fCategories); }
private Preference createWrapBeforeButton(int numColumns, String message, String setting) { Preference preference= createCheckboxPref(fOptionsGroup, 1, message, setting, FALSE_TRUE); Control control= preference.getControl(); control.setVisible(false); GridData layoutData= (GridData)control.getLayoutData(); layoutData.exclude= true; layoutData.horizontalAlignment= SWT.BEGINNING; layoutData.horizontalSpan= numColumns - 1; layoutData.grabExcessHorizontalSpace= false; return preference; }
final Group lineWidthGroup= createGroup(numColumns, composite, FormatterMessages.LineWrappingTabPage_general_settings); createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_max_line_width, DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, 0, 9999); createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_wrapped, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, 0, 9999); createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_array, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, 0, 9999); createCheckboxPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_do_not_join_lines, DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, TRUE_FALSE); createCheckboxPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_wrap_outer_expressions_when_nested, DefaultCodeFormatterConstants.FORMATTER_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED, FALSE_TRUE); final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT); gd.heightHint= fPixelConverter.convertHeightInCharsToPixels(5); fCategoriesViewer.getControl().setLayoutData(gd); fOptionsGroup = createGroup(numColumns, composite, ""); //$NON-NLS-1$ fWrappingStylePolicy= createLabel(numColumns, fOptionsGroup, FormatterMessages.LineWrappingTabPage_wrapping_policy_label_text); SWTUtil.setDefaultVisibleItemCount(fWrappingStyleCombo); fWrappingStyleCombo.setItems(WRAPPING_NAMES); fWrappingStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0)); fConditionalExpressionCategory.addPreference(createWrapBeforeButton(numColumns, FormatterMessages.LineWrappingTabPage_conditional_expression_wrap_operator, DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_CONDITIONAL_OPERATOR)); createWrapBeforeButton(numColumns, FormatterMessages.LineWrappingTabPage_binary_expression_wrap_operator, DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_BINARY_OPERATOR)); createWrapBeforeButton(numColumns, FormatterMessages.LineWrappingTabPage_multicatch_wrap_operator, DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_OR_OPERATOR_MULTICATCH)); createWrapBeforeButton(numColumns, FormatterMessages.LineWrappingTabPage_binary_expression_wrap_operator, DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_ASSIGNMENT_OPERATOR));
@Override protected void addPages(Map<String, String> values) { addTabPage(FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_parentheses_title, new ParenthesesTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_blank_lines_title, new BlankLinesTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_new_lines_title, new NewLinesTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_control_statements_title, new ControlStatementsTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_line_wrapping_title, new LineWrappingTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_comments_title, new CommentsTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_OffOnTags_title, new OffOnTagsTabPage(this, values)); }
/** * Create a new line wrapping tab page. * * @param modifyDialog the modify dialog * @param workingValues the values */ public LineWrappingTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) { super(modifyDialog, workingValues); fDialogSettings= JavaPlugin.getDefault().getDialogSettings(); final String previewLineWidth= fDialogSettings.get(PREF_PREVIEW_LINE_WIDTH); fPreviewPreferences= new HashMap<>(); fPreviewPreferences.put(LINE_SPLIT, previewLineWidth != null ? previewLineWidth : Integer.toString(DEFAULT_PREVIEW_WINDOW_LINE_WIDTH)); fCategories= createCategories(); fCategoryListener= new CategoryListener(fCategories); }
protected void forceSplitChanged(boolean forceSplit) { Iterator iterator= fSelectionState.fElements.iterator(); String currentKey; while (iterator.hasNext()) { currentKey= ((Category)iterator.next()).key; try { changeForceSplit(currentKey, forceSplit); } catch (IllegalArgumentException e) { fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(forceSplit, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e)); } } fSelectionState.refreshState(fSelection); }
protected void wrappingStyleChanged(int wrappingStyle) { Iterator<Category> iterator= fSelectionState.fElements.iterator(); String currentKey; while (iterator.hasNext()) { currentKey= iterator.next().key; try { changeWrappingStyle(currentKey, wrappingStyle); } catch (IllegalArgumentException e) { fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, wrappingStyle, DefaultCodeFormatterConstants.INDENT_DEFAULT)); JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e)); } } fSelectionState.refreshState(fSelection); }
protected void indentStyleChanged(int indentStyle) { Iterator<Category> iterator= fSelectionState.fElements.iterator(); String currentKey; while (iterator.hasNext()) { currentKey= iterator.next().key; try { changeIndentStyle(currentKey, indentStyle); } catch (IllegalArgumentException e) { fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, indentStyle)); JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e)); } } fSelectionState.refreshState(fSelection); }