@@ -146,17 +146,19 @@ void handleChildrenEvent(@UIEventTopic(UIEvents.ElementContainer.TOPIC_CHILDREN)
146146 for (Object o : UIEvents .asIterable (event , UIEvents .EventTags .NEW_VALUE )) {
147147 MPerspective added = (MPerspective ) o ;
148148 // Adding invisible elements is a NO-OP
149- if (!added .isToBeRendered ())
149+ if (!added .isToBeRendered ()) {
150150 continue ;
151+ }
151152
152153 addPerspectiveItem (added );
153154 }
154155 } else if (UIEvents .isREMOVE (event )) {
155156 for (Object o : UIEvents .asIterable (event , UIEvents .EventTags .OLD_VALUE )) {
156157 MPerspective removed = (MPerspective ) o ;
157158 // Removing invisible elements is a NO-OP
158- if (!removed .isToBeRendered ())
159+ if (!removed .isToBeRendered ()) {
159160 continue ;
161+ }
160162
161163 removePerspectiveItem (removed );
162164 }
@@ -174,8 +176,9 @@ void handleToBeRenderedEvent(@UIEventTopic(UIEvents.UIElement.TOPIC_TOBERENDERED
174176
175177 MPerspective persp = (MPerspective ) event .getProperty (UIEvents .EventTags .ELEMENT );
176178
177- if (!persp .getParent ().isToBeRendered ())
179+ if (!persp .getParent ().isToBeRendered ()) {
178180 return ;
181+ }
179182
180183 if (persp .isToBeRendered ()) {
181184 addPerspectiveItem (persp );
@@ -224,8 +227,9 @@ void handleSelectionEvent(@UIEventTopic(UIEvents.ElementContainer.TOPIC_SELECTED
224227
225228 MPerspectiveStack perspStack = (MPerspectiveStack ) changedObj ;
226229
227- if (!perspStack .isToBeRendered ())
230+ if (!perspStack .isToBeRendered ()) {
228231 return ;
232+ }
229233
230234 MPerspective selElement = perspStack .getSelectedElement ();
231235 for (ToolItem ti : perspSwitcherToolbar .getItems ()) {
@@ -256,8 +260,9 @@ void createWidget(Composite parent, MToolControl toolControl) {
256260 int orientation = SWT .HORIZONTAL ;
257261 if (meParent instanceof MTrimBar ) {
258262 MTrimBar bar = (MTrimBar ) meParent ;
259- if (bar .getSide () == SideValue .RIGHT || bar .getSide () == SideValue .LEFT )
263+ if (bar .getSide () == SideValue .RIGHT || bar .getSide () == SideValue .LEFT ) {
260264 orientation = SWT .VERTICAL ;
265+ }
261266 }
262267 comp = new Composite (parent , SWT .NONE );
263268 RowLayout layout = new RowLayout (SWT .HORIZONTAL );
@@ -276,14 +281,15 @@ void createWidget(Composite parent, MToolControl toolControl) {
276281 Point p = new Point (e .x , e .y );
277282 p = perspSwitcherToolbar .getDisplay ().map (null , perspSwitcherToolbar , p );
278283 ToolItem item = tb .getItem (p );
279- if (item == null )
284+ if (item == null ) {
280285 E4Util .message (" ToolBar menu" ); //$NON-NLS-1$
281- else {
286+ } else {
282287 MPerspective persp = (MPerspective ) item .getData ();
283- if (persp == null )
288+ if (persp == null ) {
284289 E4Util .message (" Add button Menu" ); //$NON-NLS-1$
285- else
290+ } else {
286291 openMenuFor (item , persp );
292+ }
287293 }
288294 });
289295
@@ -355,8 +361,9 @@ private boolean ignoreEvent(Object changedObj) {
355361
356362 private void track (MouseEvent e ) {
357363 // Create and track the feedback overlay
358- if (dragShell == null )
364+ if (dragShell == null ) {
359365 createFeedback ();
366+ }
360367
361368 // Move the drag shell
362369 Rectangle b = dragItem .getBounds ();
@@ -390,8 +397,9 @@ private void hookupDnD(ToolBar bar) {
390397 bar .addMouseListener (new MouseListener () {
391398 @ Override
392399 public void mouseUp (MouseEvent e ) {
393- if (dragItem == null )
400+ if (dragItem == null ) {
394401 return ;
402+ }
395403
396404 ToolBar bar = (ToolBar ) e .widget ;
397405 ToolItem curItem = bar .getItem (new Point (e .x , e .y ));
@@ -406,21 +414,24 @@ public void mouseUp(MouseEvent e) {
406414 int dragPerspIndex = dragPersp .getParent ().getChildren ().indexOf (dragPersp );
407415 MPerspective dropPersp = (MPerspective ) curItem .getData ();
408416 int dropPerspIndex = dropPersp .getParent ().getChildren ().indexOf (dropPersp );
409- if (!atStart )
417+ if (!atStart ) {
410418 dropPerspIndex ++; // We're 'after' the item we're over
419+ }
411420
412- if (dropPerspIndex > dragPerspIndex )
421+ if (dropPerspIndex > dragPerspIndex ) {
413422 dropPerspIndex --; // Need to account for the removal of
414423 // the drag item itself
424+ }
415425
416426 // If it's not a no-op move the perspective
417427 if (dropPerspIndex != dragPerspIndex ) {
418428 MElementContainer <MUIElement > parent = dragPersp .getParent ();
419429 boolean selected = dragPersp == parent .getSelectedElement ();
420430 parent .getChildren ().remove (dragPersp );
421431 parent .getChildren ().add (dropPerspIndex , dragPersp );
422- if (selected )
432+ if (selected ) {
423433 parent .setSelectedElement (dragPersp );
434+ }
424435 }
425436 }
426437
@@ -429,8 +440,9 @@ public void mouseUp(MouseEvent e) {
429440 downPos = null ;
430441 dragging = false ;
431442 perspSwitcherToolbar .setCursor (null );
432- if (dragShell != null && !dragShell .isDisposed ())
443+ if (dragShell != null && !dragShell .isDisposed ()) {
433444 dragShell .dispose ();
445+ }
434446 dragShell = null ;
435447 }
436448
@@ -442,8 +454,9 @@ public void mouseDown(MouseEvent e) {
442454
443455 // We're only interested if the button went down over a
444456 // perspective item
445- if (downItem != null && downItem .getData () instanceof MPerspective )
457+ if (downItem != null && downItem .getData () instanceof MPerspective ) {
446458 dragItem = downItem ;
459+ }
447460 }
448461
449462 @ Override
@@ -475,8 +488,9 @@ private Image getOpenPerspectiveImage() {
475488
476489 MPerspectiveStack getPerspectiveStack () {
477490 List <MPerspectiveStack > psList = modelService .findElements (window , null , MPerspectiveStack .class );
478- if (psList .size () > 0 )
491+ if (psList .size () > 0 ) {
479492 return psList .get (0 );
493+ }
480494 return null ;
481495 }
482496
@@ -500,8 +514,9 @@ private ToolItem addPerspectiveItem(MPerspective persp) {
500514
501515 psItem .addListener (SWT .Dispose , event -> {
502516 Image currentImage = psItem .getImage ();
503- if (currentImage != null )
517+ if (currentImage != null ) {
504518 currentImage .dispose ();
519+ }
505520 });
506521 foundImage = true ;
507522 psItem .setToolTipText (persp .getLocalizedLabel ());
@@ -582,8 +597,9 @@ private void addCloseItem(final Menu menu) {
582597 menuItem .setText (WorkbenchMessages .WorkbenchWindow_close );
583598 menuItem .addSelectionListener (widgetSelectedAdapter (e -> {
584599 MPerspective persp = (MPerspective ) menu .getData ();
585- if (persp != null )
600+ if (persp != null ) {
586601 closePerspective (persp );
602+ }
587603 }));
588604 }
589605
@@ -601,8 +617,9 @@ private void addSaveAsItem(final Menu menu) {
601617 workbenchWindow .getWorkbench ().getHelpSystem ().setHelp (saveAsMenuItem ,
602618 IWorkbenchHelpContextIds .SAVE_PERSPECTIVE_ACTION );
603619 saveAsMenuItem .addSelectionListener (widgetSelectedAdapter (event -> {
604- if (perspSwitcherToolbar .isDisposed ())
620+ if (perspSwitcherToolbar .isDisposed ()) {
605621 return ;
622+ }
606623 IHandlerService handlerService = workbenchWindow .getService (IHandlerService .class );
607624 IStatus status = Status .OK_STATUS ;
608625 try {
@@ -611,8 +628,9 @@ private void addSaveAsItem(final Menu menu) {
611628 status = new Status (IStatus .ERROR , PlatformUI .PLUGIN_ID , e .getMessage (), e );
612629 } catch (NotHandledException e ) {
613630 }
614- if (!status .isOK ())
631+ if (!status .isOK ()) {
615632 StatusManager .getManager ().handle (status , StatusManager .SHOW | StatusManager .LOG );
633+ }
616634 }));
617635 }
618636
@@ -623,8 +641,9 @@ private void addResetItem(final Menu menu) {
623641 workbenchWindow .getWorkbench ().getHelpSystem ().setHelp (resetMenuItem ,
624642 IWorkbenchHelpContextIds .RESET_PERSPECTIVE_ACTION );
625643 resetMenuItem .addSelectionListener (widgetSelectedAdapter (event -> {
626- if (perspSwitcherToolbar .isDisposed ())
644+ if (perspSwitcherToolbar .isDisposed ()) {
627645 return ;
646+ }
628647 IHandlerService handlerService = workbenchWindow .getService (IHandlerService .class );
629648 IStatus status = Status .OK_STATUS ;
630649 try {
@@ -633,8 +652,9 @@ private void addResetItem(final Menu menu) {
633652 status = new Status (IStatus .ERROR , PlatformUI .PLUGIN_ID , e .getMessage (), e );
634653 } catch (NotHandledException e ) {
635654 }
636- if (!status .isOK ())
655+ if (!status .isOK ()) {
637656 StatusManager .getManager ().handle (status , StatusManager .SHOW | StatusManager .LOG );
657+ }
638658 }));
639659 }
640660
@@ -681,10 +701,11 @@ private void setPropertyChangeListener() {
681701 if (IWorkbenchPreferenceConstants .SHOW_TEXT_ON_PERSPECTIVE_BAR .equals (propertyChangeEvent .getProperty ())) {
682702 Object newValue = propertyChangeEvent .getNewValue ();
683703 boolean showText = true ; // default
684- if (newValue instanceof Boolean )
704+ if (newValue instanceof Boolean ) {
685705 showText = ((Boolean ) newValue ).booleanValue ();
686- else if ("false" .equals (newValue )) //$NON-NLS-1$
706+ } else if ("false" .equals (newValue )) { //$NON-NLS-1$
687707 showText = false ;
708+ }
688709 changeShowText (showText );
689710 }
690711 };
@@ -695,10 +716,11 @@ private void changeShowText(boolean showText) {
695716 ToolItem [] items = perspSwitcherToolbar .getItems ();
696717 for (ToolItem item : items ) {
697718 MPerspective persp = (MPerspective ) item .getData ();
698- if (persp != null )
719+ if (persp != null ) {
699720 if (showText ) {
700- if (persp .getLabel () != null )
721+ if (persp .getLabel () != null ) {
701722 item .setText (persp .getLocalizedLabel ());
723+ }
702724 item .setToolTipText (persp .getLocalizedTooltip ());
703725 } else {
704726 Image image = item .getImage ();
@@ -707,6 +729,7 @@ private void changeShowText(boolean showText) {
707729 item .setToolTipText (persp .getLocalizedLabel ());
708730 }
709731 }
732+ }
710733 }
711734
712735 // update the size
@@ -734,12 +757,14 @@ private void removePerspectiveItem(MPerspective toRemove) {
734757 * @return the tool item
735758 */
736759 protected ToolItem getItemFor (MPerspective persp ) {
737- if (perspSwitcherToolbar == null )
760+ if (perspSwitcherToolbar == null ) {
738761 return null ;
762+ }
739763
740764 for (ToolItem ti : perspSwitcherToolbar .getItems ()) {
741- if (ti .getData () == persp )
765+ if (ti .getData () == persp ) {
742766 return ti ;
767+ }
743768 }
744769
745770 return null ;
@@ -779,14 +804,16 @@ private void updateToolItem(ToolItem ti, String attName, Object newValue) {
779804 ImageDescriptor descriptor = ImageDescriptor .createFromURL (url );
780805 if (descriptor == null ) {
781806 ti .setImage (null );
782- } else
807+ } else {
783808 ti .setImage (descriptor .createImage ());
809+ }
784810 } catch (IOException e ) {
785811 ti .setImage (null );
786812 logger .warn (e );
787813 } finally {
788- if (currentImage != null )
814+ if (currentImage != null ) {
789815 currentImage .dispose ();
816+ }
790817 }
791818 }
792819 }
0 commit comments