From f91a5d5301c1b857c8edf1644cc8544d13511db0 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Sun, 19 May 2019 19:59:20 +0200 Subject: [PATCH] Made formatting uniform - commit for SampleERCP --- .../.settings/org.eclipse.jdt.core.prefs | 34 +++--- SampleERCP/.settings/org.eclipse.jdt.ui.prefs | 2 +- .../src/sampleercp/handlers/AboutHandler.java | 6 +- .../src/sampleercp/handlers/OpenHandler.java | 6 +- .../src/sampleercp/handlers/QuitHandler.java | 9 +- .../src/sampleercp/handlers/SaveHandler.java | 12 +- .../src/sampleercp/parts/SamplePart.java | 15 ++- .../ExtensibleSplashHandler.java | 106 +++++++++++------- 8 files changed, 118 insertions(+), 72 deletions(-) diff --git a/SampleERCP/.settings/org.eclipse.jdt.core.prefs b/SampleERCP/.settings/org.eclipse.jdt.core.prefs index b5a253ac..a6ccee6a 100644 --- a/SampleERCP/.settings/org.eclipse.jdt.core.prefs +++ b/SampleERCP/.settings/org.eclipse.jdt.core.prefs @@ -31,7 +31,7 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=49 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 @@ -66,21 +66,21 @@ org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 org.eclipse.jdt.core.formatter.blank_lines_before_package=0 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true org.eclipse.jdt.core.formatter.comment.format_block_comments=true @@ -94,7 +94,7 @@ org.eclipse.jdt.core.formatter.comment.indent_root_tags=false org.eclipse.jdt.core.formatter.comment.indent_tag_description=false org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.line_length=140 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false @@ -127,10 +127,10 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert @@ -331,7 +331,7 @@ org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.lineSplit=140 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 diff --git a/SampleERCP/.settings/org.eclipse.jdt.ui.prefs b/SampleERCP/.settings/org.eclipse.jdt.ui.prefs index 82f3475c..f7e2228b 100644 --- a/SampleERCP/.settings/org.eclipse.jdt.ui.prefs +++ b/SampleERCP/.settings/org.eclipse.jdt.ui.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -formatter_profile=_Eclipse ajusted +formatter_profile=_ERA-MI formatter_settings_version=16 org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/SampleERCP/src/sampleercp/handlers/AboutHandler.java b/SampleERCP/src/sampleercp/handlers/AboutHandler.java index 002d74ee..f052b90c 100644 --- a/SampleERCP/src/sampleercp/handlers/AboutHandler.java +++ b/SampleERCP/src/sampleercp/handlers/AboutHandler.java @@ -4,9 +4,11 @@ import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; -public class AboutHandler { +public class AboutHandler +{ @Execute - public void execute(Shell shell) { + public void execute(Shell shell) + { MessageDialog.openInformation(shell, "About", "Sample RCP4"); } } diff --git a/SampleERCP/src/sampleercp/handlers/OpenHandler.java b/SampleERCP/src/sampleercp/handlers/OpenHandler.java index 5cc22038..15818556 100644 --- a/SampleERCP/src/sampleercp/handlers/OpenHandler.java +++ b/SampleERCP/src/sampleercp/handlers/OpenHandler.java @@ -4,10 +4,12 @@ import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; -public class OpenHandler { +public class OpenHandler +{ @Execute - public void execute(Shell shell) { + public void execute(Shell shell) + { FileDialog dialog = new FileDialog(shell); dialog.open(); } diff --git a/SampleERCP/src/sampleercp/handlers/QuitHandler.java b/SampleERCP/src/sampleercp/handlers/QuitHandler.java index 4f9d9780..7f40f8c5 100644 --- a/SampleERCP/src/sampleercp/handlers/QuitHandler.java +++ b/SampleERCP/src/sampleercp/handlers/QuitHandler.java @@ -5,10 +5,13 @@ import org.eclipse.e4.ui.workbench.IWorkbench; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; -public class QuitHandler { +public class QuitHandler +{ @Execute - public void execute(IWorkbench workbench, Shell shell) { - if (MessageDialog.openConfirm(shell, "Confirmation", "Do you want to exit?")) { + public void execute(IWorkbench workbench, Shell shell) + { + if (MessageDialog.openConfirm(shell, "Confirmation", "Do you want to exit?")) + { workbench.close(); } } diff --git a/SampleERCP/src/sampleercp/handlers/SaveHandler.java b/SampleERCP/src/sampleercp/handlers/SaveHandler.java index de086e03..c38f133c 100644 --- a/SampleERCP/src/sampleercp/handlers/SaveHandler.java +++ b/SampleERCP/src/sampleercp/handlers/SaveHandler.java @@ -4,18 +4,22 @@ import org.eclipse.e4.core.di.annotations.CanExecute; import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.ui.workbench.modeling.EPartService; -public class SaveHandler { +public class SaveHandler +{ @CanExecute - public boolean canExecute(EPartService partService) { - if (partService != null) { + public boolean canExecute(EPartService partService) + { + if (partService != null) + { return !partService.getDirtyParts().isEmpty(); } return false; } @Execute - public void execute(EPartService partService) { + public void execute(EPartService partService) + { partService.saveAll(false); } } \ No newline at end of file diff --git a/SampleERCP/src/sampleercp/parts/SamplePart.java b/SampleERCP/src/sampleercp/parts/SamplePart.java index d31046f1..93f3502d 100644 --- a/SampleERCP/src/sampleercp/parts/SamplePart.java +++ b/SampleERCP/src/sampleercp/parts/SamplePart.java @@ -17,7 +17,8 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; -public class SamplePart { +public class SamplePart +{ private TableViewer tableViewer; @@ -25,7 +26,8 @@ public class SamplePart { private MPart part; @PostConstruct - public void createComposite(Composite parent) { + public void createComposite(Composite parent) + { parent.setLayout(new GridLayout(1, false)); Text txtInput = new Text(parent, SWT.BORDER); @@ -41,16 +43,19 @@ public class SamplePart { } @Focus - public void setFocus() { + public void setFocus() + { tableViewer.getTable().setFocus(); } @Persist - public void save() { + public void save() + { part.setDirty(false); } - private static List createInitialDataModel() { + private static List createInitialDataModel() + { return Arrays.asList("Sample item 1", "Sample item 2", "Sample item 3", "Sample item 4", "Sample item 5"); } } \ No newline at end of file diff --git a/SampleERCP/src/sampleercp/splashhandlers/ExtensibleSplashHandler.java b/SampleERCP/src/sampleercp/splashhandlers/ExtensibleSplashHandler.java index 9390d124..6581eb16 100644 --- a/SampleERCP/src/sampleercp/splashhandlers/ExtensibleSplashHandler.java +++ b/SampleERCP/src/sampleercp/splashhandlers/ExtensibleSplashHandler.java @@ -21,7 +21,8 @@ import org.eclipse.ui.splash.AbstractSplashHandler; * @since 3.3 * */ -public class ExtensibleSplashHandler extends AbstractSplashHandler { +public class ExtensibleSplashHandler extends AbstractSplashHandler +{ private ArrayList fImageList; @@ -46,7 +47,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * */ - public ExtensibleSplashHandler() { + public ExtensibleSplashHandler() + { fImageList = new ArrayList<>(); fTooltipList = new ArrayList<>(); fIconPanel = null; @@ -54,12 +56,12 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /* * (non-Javadoc) - * @see - * org.eclipse.ui.splash.AbstractSplashHandler#init(org.eclipse.swt.widgets. - * Shell) + * + * @see org.eclipse.ui.splash.AbstractSplashHandler#init(org.eclipse.swt.widgets. Shell) */ @Override - public void init(Shell splash) { + public void init(Shell splash) + { // Store the shell super.init(splash); // Configure the shell layout @@ -67,7 +69,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { // Load all splash extensions loadSplashExtensions(); // If no splash extensions were loaded abort the splash handler - if (!hasSplashExtensions()) { + if (!hasSplashExtensions()) + { return; } // Create UI @@ -82,14 +85,16 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * @return */ - private boolean hasSplashExtensions() { + private boolean hasSplashExtensions() + { return !fImageList.isEmpty(); } /** * */ - private void createUI() { + private void createUI() + { // Create the icon panel createUICompositeIconPanel(); // Create the images @@ -99,7 +104,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * */ - private void createUIImages() { + private void createUIImages() + { Iterator imageIterator = fImageList.iterator(); Iterator tooltipIterator = fTooltipList.iterator(); int i = 1; @@ -107,7 +113,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { // Create all the images // Abort if we run out of columns (left-over images will not fit within // the usable splash screen width) - while (imageIterator.hasNext() && (i <= columnCount)) { + while (imageIterator.hasNext() && (i <= columnCount)) + { Image image = imageIterator.next(); String tooltip = tooltipIterator.next(); // Create the image using a label widget @@ -120,7 +127,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { * @param image * @param tooltip */ - private void createUILabel(Image image, String tooltip) { + private void createUILabel(Image image, String tooltip) + { // Create the label (no text) Label label = new Label(fIconPanel, SWT.NONE); label.setImage(image); @@ -130,7 +138,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * */ - private void createUICompositeIconPanel() { + private void createUICompositeIconPanel() + { Shell splash = getSplash(); // Create the composite fIconPanel = new Composite(splash, SWT.NONE); @@ -153,7 +162,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * */ - private void configureUICompositeIconPanelBounds() { + private void configureUICompositeIconPanelBounds() + { // Determine the size of the panel and position it at the bottom-right // of the splash screen. Point panelSize = fIconPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); @@ -169,7 +179,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * @return */ - private int getUsableSplashScreenWidth() { + private int getUsableSplashScreenWidth() + { // Splash screen width minus two graphic border bevel widths return getSplash().getSize().x - (F_SPLASH_SCREEN_BEVEL * 2); } @@ -177,12 +188,13 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * */ - private void loadSplashExtensions() { + private void loadSplashExtensions() + { // Get all splash handler extensions - IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(F_SPLASH_EXTENSION_ID) - .getExtensions(); + IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(F_SPLASH_EXTENSION_ID).getExtensions(); // Process all splash handler extensions - for (int i = 0; i < extensions.length; i++) { + for (int i = 0; i < extensions.length; i++) + { processSplashExtension(extensions[i]); } } @@ -190,11 +202,13 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * @param extension */ - private void processSplashExtension(IExtension extension) { + private void processSplashExtension(IExtension extension) + { // Get all splash handler configuration elements IConfigurationElement[] elements = extension.getConfigurationElements(); // Process all splash handler configuration elements - for (int j = 0; j < elements.length; j++) { + for (int j = 0; j < elements.length; j++) + { processSplashElements(elements[j]); } } @@ -202,7 +216,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * @param configurationElement */ - private void processSplashElements(IConfigurationElement configurationElement) { + private void processSplashElements(IConfigurationElement configurationElement) + { // Attribute: icon processSplashElementIcon(configurationElement); // Attribute: tooltip @@ -212,13 +227,16 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * @param configurationElement */ - private void processSplashElementTooltip(IConfigurationElement configurationElement) { + private void processSplashElementTooltip(IConfigurationElement configurationElement) + { // Get attribute tooltip String tooltip = configurationElement.getAttribute(F_ELEMENT_TOOLTIP); // If a tooltip is not defined, give it a default - if ((tooltip == null) || (tooltip.length() == 0)) { + if ((tooltip == null) || (tooltip.length() == 0)) + { fTooltipList.add(F_DEFAULT_TOOLTIP); - } else { + } else + { fTooltipList.add(tooltip); } } @@ -226,28 +244,33 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * @param configurationElement */ - private void processSplashElementIcon(IConfigurationElement configurationElement) { + private void processSplashElementIcon(IConfigurationElement configurationElement) + { // Get attribute icon String iconImageFilePath = configurationElement.getAttribute(F_ELEMENT_ICON); // Abort if an icon attribute was not specified - if ((iconImageFilePath == null) || (iconImageFilePath.length() == 0)) { + if ((iconImageFilePath == null) || (iconImageFilePath.length() == 0)) + { return; } // Create a corresponding image descriptor - ImageDescriptor descriptor = AbstractUIPlugin - .imageDescriptorFromPlugin(configurationElement.getNamespaceIdentifier(), iconImageFilePath); + ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(configurationElement.getNamespaceIdentifier(), + iconImageFilePath); // Abort if no corresponding image was found - if (descriptor == null) { + if (descriptor == null) + { return; } // Create the image Image image = descriptor.createImage(); // Abort if image creation failed - if (image == null) { + if (image == null) + { return; } // Abort if the image does not have dimensions of 50x50 - if ((image.getBounds().width != F_IMAGE_WIDTH) || (image.getBounds().height != F_IMAGE_HEIGHT)) { + if ((image.getBounds().width != F_IMAGE_WIDTH) || (image.getBounds().height != F_IMAGE_HEIGHT)) + { // Dipose of the image image.dispose(); return; @@ -259,7 +282,8 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * */ - private void configureUISplash() { + private void configureUISplash() + { // Configure layout GridLayout layout = new GridLayout(1, true); getSplash().setLayout(layout); @@ -270,27 +294,33 @@ public class ExtensibleSplashHandler extends AbstractSplashHandler { /** * */ - private void doEventLoop() { + private void doEventLoop() + { Shell splash = getSplash(); - if (!splash.getDisplay().readAndDispatch()) { + if (!splash.getDisplay().readAndDispatch()) + { splash.getDisplay().sleep(); } } /* * (non-Javadoc) + * * @see org.eclipse.ui.splash.AbstractSplashHandler#dispose() */ @Override - public void dispose() { + public void dispose() + { super.dispose(); // Check to see if any images were defined - if ((fImageList == null) || fImageList.isEmpty()) { + if ((fImageList == null) || fImageList.isEmpty()) + { return; } // Dispose of all the images Iterator iterator = fImageList.iterator(); - while (iterator.hasNext()) { + while (iterator.hasNext()) + { Image image = iterator.next(); image.dispose(); } -- 2.17.1