1 /******************************************************************************* 2 * Copyright (c) 2008, 2020 Angelo Zerr and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.e4.ui.css.swt.helpers; 15 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.widgets.Widget; 18 19 /** 20 * SWT Helper to get SWT styles {@link Widget} as String. 21 * 22 * @version 1.0.0 23 * @author <a href="mailto:angelo.zerr@gmail.com">Angelo ZERR</a> 24 * 25 */ 26 public class SWTStyleHelpers { 27 28 /** 29 * Return SWT style constant from {@link Widget} <code>widget</code> as 30 * String. Each SWT style are separate with space character. 31 * 32 * @param style 33 * @return 34 */ getSWTWidgetStyleAsString(Widget widget)35 public static String getSWTWidgetStyleAsString(Widget widget) { 36 if (widget.isDisposed()) { 37 return ""; 38 } 39 return getSWTWidgetStyleAsString(widget.getStyle(), " "); 40 } 41 42 /** 43 * Return SWT style constant <code>style</code> as String. Each SWT style 44 * are separate with <code>separator</code> String. 45 * 46 * @param style 47 * @return 48 */ getSWTWidgetStyleAsString(int style, String separator)49 public static String getSWTWidgetStyleAsString(int style, String separator) { 50 if (style == 0) { 51 return ""; 52 } 53 StringBuilder swtStyles = new StringBuilder(); 54 // Use catch error if SWT version doesn't provide 55 // the SWT constant 56 try { 57 if ((style & SWT.BAR) != 0) { 58 addSWTStyle(swtStyles, "SWT.BAR", separator); 59 } 60 } catch (Exception e) { 61 } 62 try { 63 if ((style & SWT.DROP_DOWN) != 0) { 64 addSWTStyle(swtStyles, "SWT.DROP_DOWN", separator); 65 } 66 } catch (Exception e) { 67 } 68 try { 69 if ((style & SWT.POP_UP) != 0) { 70 addSWTStyle(swtStyles, "SWT.POP_UP", separator); 71 } 72 } catch (Exception e) { 73 } 74 try { 75 if ((style & SWT.SEPARATOR) != 0) { 76 addSWTStyle(swtStyles, "SWT.SEPARATOR", separator); 77 } 78 } catch (Exception e) { 79 } 80 try { 81 if ((style & SWT.TOGGLE) != 0) { 82 addSWTStyle(swtStyles, "SWT.TOGGLE", separator); 83 } 84 } catch (Exception e) { 85 } 86 try { 87 if ((style & SWT.ARROW) != 0) { 88 addSWTStyle(swtStyles, "SWT.ARROW", separator); 89 } 90 } catch (Exception e) { 91 } 92 try { 93 if ((style & SWT.PUSH) != 0) { 94 addSWTStyle(swtStyles, "SWT.PUSH", separator); 95 } 96 } catch (Exception e) { 97 } 98 try { 99 if ((style & SWT.RADIO) != 0) { 100 addSWTStyle(swtStyles, "SWT.RADIO", separator); 101 } 102 } catch (Exception e) { 103 } 104 try { 105 if ((style & SWT.CHECK) != 0) { 106 addSWTStyle(swtStyles, "SWT.CHECK", separator); 107 } 108 } catch (Exception e) { 109 } 110 try { 111 if ((style & SWT.CASCADE) != 0) { 112 addSWTStyle(swtStyles, "SWT.CASCADE", separator); 113 } 114 } catch (Exception e) { 115 } 116 try { 117 if ((style & SWT.MULTI) != 0) { 118 addSWTStyle(swtStyles, "SWT.MULTI", separator); 119 } 120 } catch (Exception e) { 121 } 122 try { 123 if ((style & SWT.SINGLE) != 0) { 124 addSWTStyle(swtStyles, "SWT.SINGLE", separator); 125 } 126 } catch (Exception e) { 127 } 128 try { 129 if ((style & SWT.READ_ONLY) != 0) { 130 addSWTStyle(swtStyles, "SWT.READ_ONLY", separator); 131 } 132 } catch (Exception e) { 133 } 134 try { 135 if ((style & SWT.WRAP) != 0) { 136 addSWTStyle(swtStyles, "SWT.WRAP", separator); 137 } 138 } catch (Exception e) { 139 } 140 try { 141 if ((style & SWT.SEARCH) != 0) { 142 addSWTStyle(swtStyles, "SWT.SEARCH", separator); 143 } 144 } catch (Exception e) { 145 } 146 try { 147 if ((style & SWT.SIMPLE) != 0) { 148 addSWTStyle(swtStyles, "SWT.SIMPLE", separator); 149 } 150 } catch (Exception e) { 151 } 152 try { 153 if ((style & SWT.PASSWORD) != 0) { 154 addSWTStyle(swtStyles, "SWT.PASSWORD", separator); 155 } 156 } catch (Exception e) { 157 } 158 try { 159 if ((style & SWT.SHADOW_IN) != 0) { 160 addSWTStyle(swtStyles, "SWT.SHADOW_IN", separator); 161 } 162 } catch (Exception e) { 163 } 164 try { 165 if ((style & SWT.SHADOW_OUT) != 0) { 166 addSWTStyle(swtStyles, "SWT.SHADOW_OUT", separator); 167 } 168 } catch (Exception e) { 169 } 170 try { 171 if ((style & SWT.SHADOW_ETCHED_IN) != 0) { 172 addSWTStyle(swtStyles, "SWT.SHADOW_ETCHED_IN", separator); 173 } 174 } catch (Exception e) { 175 } 176 try { 177 if ((style & SWT.SHADOW_ETCHED_OUT) != 0) { 178 addSWTStyle(swtStyles, "SWT.SHADOW_ETCHED_OUT", separator); 179 } 180 } catch (Exception e) { 181 } 182 try { 183 if ((style & SWT.SHADOW_NONE) != 0) { 184 addSWTStyle(swtStyles, "SWT.SHADOW_NONE", separator); 185 } 186 } catch (Exception e) { 187 } 188 try { 189 if ((style & SWT.INDETERMINATE) != 0) { 190 addSWTStyle(swtStyles, "SWT.INDETERMINATE", separator); 191 } 192 } catch (Exception e) { 193 } 194 try { 195 if ((style & SWT.TOOL) != 0) { 196 addSWTStyle(swtStyles, "SWT.TOOL", separator); 197 } 198 } catch (Exception e) { 199 } 200 try { 201 if ((style & SWT.NO_TRIM) != 0) { 202 addSWTStyle(swtStyles, "SWT.NO_TRIM", separator); 203 } 204 } catch (Exception e) { 205 } 206 try { 207 if ((style & SWT.RESIZE) != 0) { 208 addSWTStyle(swtStyles, "SWT.RESIZE", separator); 209 } 210 } catch (Exception e) { 211 } 212 try { 213 if ((style & SWT.TITLE) != 0) { 214 addSWTStyle(swtStyles, "SWT.TITLE", separator); 215 } 216 } catch (Exception e) { 217 } 218 try { 219 if ((style & SWT.CLOSE) != 0) { 220 addSWTStyle(swtStyles, "SWT.CLOSE", separator); 221 } 222 } catch (Exception e) { 223 } 224 try { 225 if ((style & SWT.MENU) != 0) { 226 addSWTStyle(swtStyles, "SWT.MENU", separator); 227 } 228 } catch (Exception e) { 229 } 230 try { 231 if ((style & SWT.MIN) != 0) { 232 addSWTStyle(swtStyles, "SWT.MIN", separator); 233 } 234 } catch (Exception e) { 235 } 236 try { 237 if ((style & SWT.MAX) != 0) { 238 addSWTStyle(swtStyles, "SWT.MAX", separator); 239 } 240 } catch (Exception e) { 241 } 242 try { 243 if ((style & SWT.H_SCROLL) != 0) { 244 addSWTStyle(swtStyles, "SWT.H_SCROLL", separator); 245 } 246 } catch (Exception e) { 247 } 248 try { 249 if ((style & SWT.V_SCROLL) != 0) { 250 addSWTStyle(swtStyles, "SWT.V_SCROLL", separator); 251 } 252 } catch (Exception e) { 253 } 254 try { 255 if ((style & SWT.BORDER) != 0) { 256 addSWTStyle(swtStyles, "SWT.BORDER", separator); 257 } 258 } catch (Exception e) { 259 } 260 try { 261 if ((style & SWT.CLIP_CHILDREN) != 0) { 262 addSWTStyle(swtStyles, "SWT.CLIP_CHILDREN", separator); 263 } 264 } catch (Exception e) { 265 } 266 try { 267 if ((style & SWT.CLIP_SIBLINGS) != 0) { 268 addSWTStyle(swtStyles, "SWT.CLIP_SIBLINGS", separator); 269 } 270 } catch (Exception e) { 271 } 272 try { 273 if ((style & SWT.ON_TOP) != 0) { 274 addSWTStyle(swtStyles, "SWT.ON_TOP", separator); 275 } 276 } catch (Exception e) { 277 } 278 try { 279 if ((style & SWT.SHELL_TRIM) != 0) { 280 addSWTStyle(swtStyles, "SWT.SHELL_TRIM", separator); 281 } 282 } catch (Exception e) { 283 } 284 try { 285 if ((style & SWT.DIALOG_TRIM) != 0) { 286 addSWTStyle(swtStyles, "SWT.DIALOG_TRIM", separator); 287 } 288 } catch (Exception e) { 289 } 290 try { 291 if ((style & SWT.MODELESS) != 0) { 292 addSWTStyle(swtStyles, "SWT.MODELESS", separator); 293 } 294 } catch (Exception e) { 295 } 296 try { 297 if ((style & SWT.MODELESS) != 0) { 298 addSWTStyle(swtStyles, "SWT.MODELESS", separator); 299 } 300 } catch (Exception e) { 301 } 302 try { 303 if ((style & SWT.PRIMARY_MODAL) != 0) { 304 addSWTStyle(swtStyles, "SWT.PRIMARY_MODAL", separator); 305 } 306 } catch (Exception e) { 307 } 308 try { 309 if ((style & SWT.APPLICATION_MODAL) != 0) { 310 addSWTStyle(swtStyles, "SWT.APPLICATION_MODAL", separator); 311 } 312 } catch (Exception e) { 313 } 314 try { 315 if ((style & SWT.SYSTEM_MODAL) != 0) { 316 addSWTStyle(swtStyles, "SWT.SYSTEM_MODAL", separator); 317 } 318 } catch (Exception e) { 319 } 320 try { 321 if ((style & SWT.HIDE_SELECTION) != 0) { 322 addSWTStyle(swtStyles, "SWT.HIDE_SELECTION", separator); 323 } 324 } catch (Exception e) { 325 } 326 try { 327 if ((style & SWT.FULL_SELECTION) != 0) { 328 addSWTStyle(swtStyles, "SWT.FULL_SELECTION", separator); 329 } 330 } catch (Exception e) { 331 } 332 try { 333 if ((style & SWT.FLAT) != 0) { 334 addSWTStyle(swtStyles, "SWT.FLAT", separator); 335 } 336 } catch (Exception e) { 337 } 338 try { 339 if ((style & SWT.SMOOTH) != 0) { 340 addSWTStyle(swtStyles, "SWT.SMOOTH", separator); 341 } 342 } catch (Exception e) { 343 } 344 try { 345 if ((style & SWT.NO_BACKGROUND) != 0) { 346 addSWTStyle(swtStyles, "SWT.NO_BACKGROUND", separator); 347 } 348 } catch (Exception e) { 349 } 350 try { 351 if ((style & SWT.NO_FOCUS) != 0) { 352 addSWTStyle(swtStyles, "SWT.NO_FOCUS", separator); 353 } 354 } catch (Exception e) { 355 } 356 try { 357 if ((style & SWT.NO_REDRAW_RESIZE) != 0) { 358 addSWTStyle(swtStyles, "SWT.NO_REDRAW_RESIZE", separator); 359 } 360 } catch (Exception e) { 361 } 362 try { 363 if ((style & SWT.NO_MERGE_PAINTS) != 0) { 364 addSWTStyle(swtStyles, "SWT.NO_MERGE_PAINTS", separator); 365 } 366 } catch (Exception e) { 367 } 368 try { 369 if ((style & SWT.NO_RADIO_GROUP) != 0) { 370 addSWTStyle(swtStyles, "SWT.NO_RADIO_GROUP", separator); 371 } 372 } catch (Exception e) { 373 } 374 try { 375 if ((style & SWT.LEFT_TO_RIGHT) != 0) { 376 addSWTStyle(swtStyles, "SWT.LEFT_TO_RIGHT", separator); 377 } 378 } catch (Exception e) { 379 } 380 try { 381 if ((style & SWT.RIGHT_TO_LEFT) != 0) { 382 addSWTStyle(swtStyles, "SWT.RIGHT_TO_LEFT", separator); 383 } 384 } catch (Exception e) { 385 } 386 try { 387 if ((style & SWT.MIRRORED) != 0) { 388 addSWTStyle(swtStyles, "SWT.MIRRORED", separator); 389 } 390 } catch (Exception e) { 391 } 392 try { 393 if ((style & SWT.VIRTUAL) != 0) { 394 addSWTStyle(swtStyles, "SWT.VIRTUAL", separator); 395 } 396 } catch (Exception e) { 397 } 398 try { 399 if ((style & SWT.DOUBLE_BUFFERED) != 0) { 400 addSWTStyle(swtStyles, "SWT.DOUBLE_BUFFERED", separator); 401 } 402 } catch (Exception e) { 403 } 404 try { 405 if ((style & SWT.UP) != 0) { 406 addSWTStyle(swtStyles, "SWT.UP", separator); 407 } 408 } catch (Exception e) { 409 } 410 try { 411 if ((style & SWT.TOP) != 0) { 412 addSWTStyle(swtStyles, "SWT.TOP", separator); 413 } 414 } catch (Exception e) { 415 } 416 try { 417 if ((style & SWT.DOWN) != 0) { 418 addSWTStyle(swtStyles, "SWT.DOWN", separator); 419 } 420 } catch (Exception e) { 421 } 422 try { 423 if ((style & SWT.BOTTOM) != 0) { 424 addSWTStyle(swtStyles, "SWT.BOTTOM", separator); 425 } 426 } catch (Exception e) { 427 } 428 try { 429 if ((style & SWT.LEAD) != 0) { 430 addSWTStyle(swtStyles, "SWT.LEAD", separator); 431 } 432 } catch (Exception e) { 433 } 434 try { 435 if ((style & SWT.LEFT) != 0) { 436 addSWTStyle(swtStyles, "SWT.LEFT", separator); 437 } 438 } catch (Exception e) { 439 } 440 try { 441 if ((style & SWT.TRAIL) != 0) { 442 addSWTStyle(swtStyles, "SWT.TRAIL", separator); 443 } 444 } catch (Exception e) { 445 } 446 try { 447 if ((style & SWT.RIGHT) != 0) { 448 addSWTStyle(swtStyles, "SWT.RIGHT", separator); 449 } 450 } catch (Exception e) { 451 } 452 try { 453 if ((style & SWT.CENTER) != 0) { 454 addSWTStyle(swtStyles, "SWT.CENTER", separator); 455 } 456 } catch (Exception e) { 457 } 458 try { 459 if ((style & SWT.HORIZONTAL) != 0) { 460 addSWTStyle(swtStyles, "SWT.HORIZONTAL", separator); 461 } 462 } catch (Exception e) { 463 } 464 try { 465 if ((style & SWT.VERTICAL) != 0) { 466 addSWTStyle(swtStyles, "SWT.VERTICAL", separator); 467 } 468 } catch (Exception e) { 469 } 470 try { 471 if ((style & SWT.DATE) != 0) { 472 addSWTStyle(swtStyles, "SWT.DATE", separator); 473 } 474 } catch (Exception e) { 475 } 476 try { 477 if ((style & SWT.TIME) != 0) { 478 addSWTStyle(swtStyles, "SWT.TIME", separator); 479 } 480 } catch (Exception e) { 481 } 482 try { 483 if ((style & SWT.CALENDAR) != 0) { 484 addSWTStyle(swtStyles, "SWT.CALENDAR", separator); 485 } 486 } catch (Exception e) { 487 } 488 try { 489 if ((style & SWT.SHORT) != 0) { 490 addSWTStyle(swtStyles, "SWT.SHORT", separator); 491 } 492 } catch (Exception e) { 493 } 494 try { 495 if ((style & SWT.MEDIUM) != 0) { 496 addSWTStyle(swtStyles, "SWT.MEDIUM", separator); 497 } 498 } catch (Exception e) { 499 } 500 try { 501 if ((style & SWT.LONG) != 0) { 502 addSWTStyle(swtStyles, "SWT.LONG", separator); 503 } 504 } catch (Exception e) { 505 } 506 try { 507 if ((style & SWT.BALLOON) != 0) { 508 addSWTStyle(swtStyles, "SWT.BALLOON", separator); 509 } 510 } catch (Exception e) { 511 } 512 try { 513 if ((style & SWT.BEGINNING) != 0) { 514 addSWTStyle(swtStyles, "SWT.BEGINNING", separator); 515 } 516 } catch (Exception e) { 517 } 518 try { 519 if ((style & SWT.FILL) != 0) { 520 addSWTStyle(swtStyles, "SWT.FILL", separator); 521 } 522 } catch (Exception e) { 523 } 524 try { 525 if ((style & SWT.DBCS) != 0) { 526 addSWTStyle(swtStyles, "SWT.DBCS", separator); 527 } 528 } catch (Exception e) { 529 } 530 try { 531 if ((style & SWT.ALPHA) != 0) { 532 addSWTStyle(swtStyles, "SWT.ALPHA", separator); 533 } 534 } catch (Exception e) { 535 } 536 try { 537 if ((style & SWT.NATIVE) != 0) { 538 addSWTStyle(swtStyles, "SWT.NATIVE", separator); 539 } 540 } catch (Exception e) { 541 } 542 try { 543 if ((style & SWT.PHONETIC) != 0) { 544 addSWTStyle(swtStyles, "SWT.PHONETIC", separator); 545 } 546 } catch (Exception e) { 547 } 548 try { 549 if ((style & SWT.ROMAN) != 0) { 550 addSWTStyle(swtStyles, "SWT.ROMAN", separator); 551 } 552 } catch (Exception e) { 553 } 554 try { 555 if ((style & SWT.ICON_ERROR) != 0) { 556 addSWTStyle(swtStyles, "SWT.ICON_ERROR", separator); 557 } 558 } catch (Exception e) { 559 } 560 try { 561 if ((style & SWT.ICON_INFORMATION) != 0) { 562 addSWTStyle(swtStyles, "SWT.ICON_INFORMATION", separator); 563 } 564 } catch (Exception e) { 565 } 566 try { 567 if ((style & SWT.ICON_QUESTION) != 0) { 568 addSWTStyle(swtStyles, "SWT.ICON_QUESTION", separator); 569 } 570 } catch (Exception e) { 571 } 572 try { 573 if ((style & SWT.ICON_WARNING) != 0) { 574 addSWTStyle(swtStyles, "SWT.ICON_WARNING", separator); 575 } 576 } catch (Exception e) { 577 } 578 try { 579 if ((style & SWT.ICON_WORKING) != 0) { 580 addSWTStyle(swtStyles, "SWT.ICON_WORKING", separator); 581 } 582 } catch (Exception e) { 583 } 584 try { 585 if ((style & SWT.OK) != 0) { 586 addSWTStyle(swtStyles, "SWT.OK", separator); 587 } 588 } catch (Exception e) { 589 } 590 try { 591 if ((style & SWT.YES) != 0) { 592 addSWTStyle(swtStyles, "SWT.YES", separator); 593 } 594 } catch (Exception e) { 595 } 596 try { 597 if ((style & SWT.NO) != 0) { 598 addSWTStyle(swtStyles, "SWT.NO", separator); 599 } 600 } catch (Exception e) { 601 } 602 try { 603 if ((style & SWT.CANCEL) != 0) { 604 addSWTStyle(swtStyles, "SWT.CANCEL", separator); 605 } 606 } catch (Exception e) { 607 } 608 try { 609 if ((style & SWT.ABORT) != 0) { 610 addSWTStyle(swtStyles, "SWT.ABORT", separator); 611 } 612 } catch (Exception e) { 613 } 614 try { 615 if ((style & SWT.RETRY) != 0) { 616 addSWTStyle(swtStyles, "SWT.RETRY", separator); 617 } 618 } catch (Exception e) { 619 } 620 try { 621 if ((style & SWT.IGNORE) != 0) { 622 addSWTStyle(swtStyles, "SWT.IGNORE", separator); 623 } 624 } catch (Exception e) { 625 } 626 try { 627 if ((style & SWT.OPEN) != 0) { 628 addSWTStyle(swtStyles, "SWT.OPEN", separator); 629 } 630 } catch (Exception e) { 631 } 632 try { 633 if ((style & SWT.SAVE) != 0) { 634 addSWTStyle(swtStyles, "SWT.SAVE", separator); 635 } 636 } catch (Exception e) { 637 } 638 try { 639 if ((style & SWT.INHERIT_NONE) != 0) { 640 addSWTStyle(swtStyles, "SWT.INHERIT_NONE", separator); 641 } 642 } catch (Exception e) { 643 } 644 try { 645 if ((style & SWT.INHERIT_DEFAULT) != 0) { 646 addSWTStyle(swtStyles, "SWT.INHERIT_DEFAULT", separator); 647 } 648 } catch (Exception e) { 649 } 650 try { 651 if ((style & SWT.INHERIT_FORCE) != 0) { 652 addSWTStyle(swtStyles, "SWT.INHERIT_FORCE", separator); 653 } 654 } catch (Exception e) { 655 } 656 try { 657 if ((style & SWT.ERROR_MENU_NOT_DROP_DOWN) != 0) { 658 addSWTStyle(swtStyles, "SWT.ERROR_MENU_NOT_DROP_DOWN", 659 separator); 660 } 661 } catch (Exception e) { 662 } 663 try { 664 if ((style & SWT.ERROR_MENUITEM_NOT_CASCADE) != 0) { 665 addSWTStyle(swtStyles, "SWT.ERROR_MENUITEM_NOT_CASCADE", 666 separator); 667 } 668 } catch (Exception e) { 669 } 670 try { 671 if ((style & SWT.ERROR_MENU_NOT_BAR) != 0) { 672 addSWTStyle(swtStyles, "SWT.ERROR_MENU_NOT_BAR", separator); 673 } 674 } catch (Exception e) { 675 } 676 try { 677 if ((style & SWT.ERROR_MENU_NOT_POP_UP) != 0) { 678 addSWTStyle(swtStyles, "SWT.ERROR_MENU_NOT_POP_UP", separator); 679 } 680 } catch (Exception e) { 681 } 682 try { 683 if ((style & SWT.NORMAL) != 0) { 684 addSWTStyle(swtStyles, "SWT.NORMAL", separator); 685 } 686 } catch (Exception e) { 687 } 688 try { 689 if ((style & SWT.BOLD) != 0) { 690 addSWTStyle(swtStyles, "SWT.BOLD", separator); 691 } 692 } catch (Exception e) { 693 } 694 try { 695 if ((style & SWT.ITALIC) != 0) { 696 addSWTStyle(swtStyles, "SWT.ITALIC", separator); 697 } 698 } catch (Exception e) { 699 } 700 try { 701 if ((style & SWT.CAP_FLAT) != 0) { 702 addSWTStyle(swtStyles, "SWT.CAP_FLAT", separator); 703 } 704 } catch (Exception e) { 705 } 706 try { 707 if ((style & SWT.CAP_ROUND) != 0) { 708 addSWTStyle(swtStyles, "SWT.CAP_ROUND", separator); 709 } 710 } catch (Exception e) { 711 } 712 try { 713 if ((style & SWT.CAP_SQUARE) != 0) { 714 addSWTStyle(swtStyles, "SWT.CAP_SQUARE", separator); 715 } 716 } catch (Exception e) { 717 } 718 try { 719 if ((style & SWT.JOIN_MITER) != 0) { 720 addSWTStyle(swtStyles, "SWT.JOIN_MITER", separator); 721 } 722 } catch (Exception e) { 723 } 724 try { 725 if ((style & SWT.JOIN_BEVEL) != 0) { 726 addSWTStyle(swtStyles, "SWT.JOIN_BEVEL", separator); 727 } 728 } catch (Exception e) { 729 } 730 try { 731 if ((style & SWT.LINE_SOLID) != 0) { 732 addSWTStyle(swtStyles, "SWT.LINE_SOLID", separator); 733 } 734 } catch (Exception e) { 735 } 736 try { 737 if ((style & SWT.LINE_DASH) != 0) { 738 addSWTStyle(swtStyles, "SWT.LINE_DASH", separator); 739 } 740 } catch (Exception e) { 741 } 742 try { 743 if ((style & SWT.LINE_DOT) != 0) { 744 addSWTStyle(swtStyles, "SWT.LINE_DOT", separator); 745 } 746 } catch (Exception e) { 747 } 748 try { 749 if ((style & SWT.LINE_DASHDOT) != 0) { 750 addSWTStyle(swtStyles, "SWT.LINE_DASHDOT", separator); 751 } 752 } catch (Exception e) { 753 } 754 try { 755 if ((style & SWT.LINE_DASHDOTDOT) != 0) { 756 addSWTStyle(swtStyles, "SWT.LINE_DASHDOTDOT", separator); 757 } 758 } catch (Exception e) { 759 } 760 try { 761 if ((style & SWT.LINE_CUSTOM) != 0) { 762 addSWTStyle(swtStyles, "SWT.LINE_CUSTOM", separator); 763 } 764 } catch (Exception e) { 765 } 766 return swtStyles.length() == 0 ? "" : swtStyles.toString(); 767 } 768 769 /** 770 * Add SWT String <code>style</code> to the {@link StringBuilder} 771 * <cod>swtStyles</code> and separate it with <code>separator</code> 772 * String. 773 * 774 * @param swtStyles 775 * @param style 776 * @param separator 777 */ addSWTStyle(StringBuilder swtStyles, String style, String separator)778 private static void addSWTStyle(StringBuilder swtStyles, String style, 779 String separator) { 780 if (swtStyles.length() > 0) { 781 swtStyles.append(separator); 782 } 783 swtStyles.append(style); 784 } 785 } 786