| 1 23 package org.objectweb.clif.scenario.util.isac.loadprofile.gui; 24 25 import java.util.Enumeration ; 26 import java.util.Hashtable ; 27 import java.util.Vector ; 28 29 import org.apache.log4j.Category; 30 import org.eclipse.jface.dialogs.MessageDialog; 31 import org.eclipse.jface.wizard.WizardDialog; 32 import org.eclipse.swt.SWT; 33 import org.eclipse.swt.custom.ScrolledComposite; 34 import org.eclipse.swt.events.ModifyEvent; 35 import org.eclipse.swt.events.ModifyListener; 36 import org.eclipse.swt.events.MouseEvent; 37 import org.eclipse.swt.events.MouseListener; 38 import org.eclipse.swt.events.MouseMoveListener; 39 import org.eclipse.swt.events.PaintEvent; 40 import org.eclipse.swt.events.PaintListener; 41 import org.eclipse.swt.events.SelectionEvent; 42 import org.eclipse.swt.events.SelectionListener; 43 import org.eclipse.swt.graphics.Color; 44 import org.eclipse.swt.graphics.Cursor; 45 import org.eclipse.swt.graphics.GC; 46 import org.eclipse.swt.graphics.Image; 47 import org.eclipse.swt.graphics.Rectangle; 48 import org.eclipse.swt.layout.FillLayout; 49 import org.eclipse.swt.layout.GridData; 50 import org.eclipse.swt.layout.GridLayout; 51 import org.eclipse.swt.widgets.Composite; 52 import org.eclipse.swt.widgets.Event; 53 import org.eclipse.swt.widgets.Label; 54 import org.eclipse.swt.widgets.Listener; 55 import org.eclipse.swt.widgets.Menu; 56 import org.eclipse.swt.widgets.MenuItem; 57 import org.eclipse.swt.widgets.Text; 58 import org.eclipse.swt.widgets.ToolBar; 59 import org.eclipse.swt.widgets.ToolItem; 60 import org.objectweb.clif.scenario.util.isac.FileName; 61 import org.objectweb.clif.scenario.util.isac.gui.Icons; 62 import org.objectweb.clif.scenario.util.isac.gui.ScenarioGUIEditor; 63 import org.objectweb.clif.scenario.util.isac.loadprofile.GroupDescription; 64 import org.objectweb.clif.scenario.util.isac.loadprofile.LoadProfileManager; 65 import org.objectweb.clif.scenario.util.isac.loadprofile.Point; 66 import org.objectweb.clif.scenario.util.isac.loadprofile.RampDescription; 67 import org.objectweb.clif.scenario.util.isac.util.tree.TreeManager; 68 69 75 public class LoadDrawingEditor 76 implements 77 MouseListener, 78 MouseMoveListener, 79 SelectionListener, 80 Listener, 81 PaintListener, 82 ModifyListener { 83 private static final boolean SHOW_WARNING_DIALOGS = true; 85 86 private ScenarioGUIEditor window; 87 private Composite parent; 88 private Composite content; 89 private Composite toolBarComposite; 90 private Composite drawBarComposite; 91 private ScrolledComposite main; 92 private DrawableCanvas drawableCanvas; 93 private Composite canvasComposite; 94 private Point first; 96 private Point last; 97 private ToolBar toolBar; 99 private MenuItem showTextPopupItem; 100 private ToolItem createGroupToolBarItem; 101 private ToolItem selectionToolBarItem; 102 private Menu selectionMenu; 103 private Hashtable selectionMenuItems; 104 private ToolItem editDescriptionToolBarItem; 105 private ToolItem deleteSelectionToolBarItem; 106 private ToolItem changeScaleToolBarItem; 107 private ToolBar drawBarLeft; 109 private ToolBar drawBarRight; 110 private ToolItem addPointDrawBarItem ; 111 private ToolItem deletePointDrawBarItem ; 112 private ToolItem selectionPointDrawBarItem; 113 private ToolItem drawNothingDrawBarItem; 114 private ToolItem drawLineDrawBarItem; 115 private ToolItem drawCrenelHVDrawBarItem; 116 private ToolItem drawCrenelVHDrawBarItem; 117 private MenuItem showTextDrawPopupItem; 118 private ToolItem normalViewBarItem; 119 private ToolItem maximizedViewBarItem; 120 private Text xAxisText; 121 private Text yAxisText; 122 private LoadProfileManager loadManager; 124 private Image selectionImg; 126 static Category cat = Category.getInstance(LoadDrawingEditor.class 128 .getName()); 129 private static final int DRAW_NOTHING = 0; 131 private static final int DRAW_LINE = 1; 132 private static final int CHANGE_POINT = 2; 133 private static final int SELECTION_POINT = 3; 134 private static final int DRAW_CRENEL_HV = 4; 135 private static final int DRAW_CRENEL_VH = 5; 136 private static final int ADD_POINT_MODE = 6 ; 137 private static final int DELETE_POINT_MODE = 7 ; 138 139 private int currentMode; 141 private GroupDescription groupDescriptionSelected; 145 private Point pointSelected = null; 146 private ScaleConvertor scaleConvertor; 148 private static final String deletePointText = "Delete point" ; 150 private static final String deletePointToolTip = "This mode permit to delete a selected point" ; 151 private static final String addPointText = "Add point" ; 152 private static final String addPointToolTip = "Add a new point" ; 153 private static final String drawCrenelHVText = "Draw Crenel"; 154 private static final String drawCrenelVHText = "Draw Crenel"; 155 private static final String drawCrenelHVToolTipText = "Draw a Crenel composed by two lines, the first one is horizontal and the second one vertical"; 156 private static final String drawCrenelVHToolTipText = "Draw a Crenel composed by two lines, the first one is vertical and the second one horizontal"; 157 private static final String drawNothingText = "Normal Mode"; 158 private static final String drawNothingToolTipText = "This is the default mode, it draw nothing..."; 159 private static final String drawLineText = "Draw Line"; 160 private static final String drawLineEmptyRampToolTipText = "Draw a new line for this ramp"; 161 private static final String drawLineToolTipText = drawLineText + "\n" 162 + "The starting point of the new line is the last point \n" 163 + "of the existing ramp curve"; 164 private static final String maximizedViewText = "Maximize View"; 165 private static final String normalViewText = "Normal View"; 166 private static final String maximizedViewToolTipText = "Set the maximize the current view"; 167 private static final String normalViewToolItemText = "Set the normal view"; 168 private static final String xAxisLabel = "X : "; 170 private static final String yAxisLabel = "Y : "; 171 private static final String axisEditorsToolTipText = "Click with the middle mouse button on a selectable point to edit it coordinates..."; 172 private static final String changeScaleText = "Change scale"; 173 private static final String changeScaleToolTipText = "Change the scale of the drawable editor"; 174 private static final String showTextPopupText = "Show Text"; 175 private static final String createGroupToolBarText = "Create Group.."; 176 private static final String deleteSelectionText = "Delete Selection"; 177 private static final String deleteSelectionToolTipText = "Delete the group description selected"; 178 private static final String selectionText = "Select Group"; 179 private static final String editDescriptionText = "Edit Properties"; 180 private static final String editDescriptionToolTipText = "Edit the description of the selected element"; 181 private static final String createRampInformationTitle = "Create Ramp First"; 183 private static final String createRampInformationContent = "There is no ramp description created\n" 184 + "Create a ramp description first !\n"; 185 private static final String createBehaviorInformationTitle = "Create Behavior First"; 186 private static final String createBehaviorInformationContent = "There is no behavior created\n" 187 + "Create a behavior first !\n"; 188 189 public static Color defaultColor = null; 191 192 198 public LoadDrawingEditor(Composite parent, ScenarioGUIEditor w) { 199 cat.debug("-> constructor"); 200 defaultColor = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK); 202 203 this.window = w; 205 this.loadManager = LoadProfileManager.getInstance(); 207 this.loadManager.setDrawablePart(this); 208 this.scaleConvertor = new ScaleConvertor(); 210 this.parent = new Composite(parent, SWT.FLAT); 212 GridLayout gridLayout = new GridLayout(); 214 gridLayout.numColumns = 1; 215 gridLayout.marginHeight = 0; 216 gridLayout.marginWidth = 0; 217 gridLayout.verticalSpacing = 4; 218 this.parent.setLayout(gridLayout); 219 this.toolBarComposite = new Composite(this.parent, SWT.BORDER); 221 GridData gridDataToolBar = new GridData(); 223 gridDataToolBar.grabExcessHorizontalSpace = true; 224 gridDataToolBar.horizontalAlignment = GridData.FILL; 225 this.toolBarComposite.setLayoutData(gridDataToolBar); 226 this.initToolBar(); 228 this.content = new Composite(this.parent, SWT.FLAT); 230 GridLayout gridContent = new GridLayout(); 231 gridContent.marginHeight = 0; 232 gridContent.marginWidth = 0; 233 gridContent.horizontalSpacing = 4; 234 gridContent.numColumns = 2; 235 content.setLayout(gridContent); 236 GridData dataContent = new GridData(); 237 dataContent.grabExcessHorizontalSpace = true; 238 dataContent.grabExcessVerticalSpace = true; 239 dataContent.verticalAlignment = GridData.FILL; 240 dataContent.horizontalAlignment = GridData.FILL; 241 content.setLayoutData(dataContent); 242 243 this.drawBarComposite = new Composite(content, SWT.BORDER); 245 GridData gridDataDrawBar = new GridData(); 246 gridDataDrawBar.verticalAlignment = GridData.FILL; 247 gridDataDrawBar.grabExcessVerticalSpace = true; 248 this.drawBarComposite.setLayoutData(gridDataDrawBar); 249 250 this.main = new ScrolledComposite(content, SWT.BORDER | SWT.H_SCROLL 252 | SWT.V_SCROLL); 253 this.main.setAlwaysShowScrollBars(false); 254 GridData gridDataContents = new GridData(); 255 gridDataContents.horizontalAlignment = GridData.FILL; 256 gridDataContents.verticalAlignment = GridData.FILL; 257 gridDataContents.grabExcessHorizontalSpace = true; 258 gridDataContents.grabExcessVerticalSpace = true; 259 this.main.setLayoutData(gridDataContents); 260 this.main.setExpandHorizontal(true); 261 this.main.setExpandVertical(true); 262 263 this.initDrawBar(); 265 266 this.initDrawablePart(); 268 269 this.parent.layout(); 270 this.first = new Point(-1, -1); 272 this.last = new Point(-1, -1); 273 274 this.currentMode = DRAW_NOTHING; 276 } 277 278 281 private void initDrawBar() { 282 cat.debug("-> initDrawBar"); 283 GridLayout gridDrawBarComposite = new GridLayout(); 285 gridDrawBarComposite.numColumns = 2; 286 this.drawBarComposite.setLayout(gridDrawBarComposite); 287 this.drawBarLeft = new ToolBar(this.drawBarComposite, SWT.VERTICAL 289 | SWT.FLAT); 290 GridData gridDrawBarLeftData = new GridData(); 292 gridDrawBarLeftData.horizontalAlignment = GridData.FILL; 293 gridDrawBarLeftData.verticalAlignment = GridData.FILL; 294 gridDrawBarLeftData.grabExcessVerticalSpace = true ; 295 this.drawBarLeft.setLayoutData(gridDrawBarLeftData); 296 this.drawBarRight = new ToolBar(this.drawBarComposite, SWT.VERTICAL 298 | SWT.FLAT); 299 GridData gridDrawBarRightData = new GridData(); 301 gridDrawBarRightData.horizontalAlignment = GridData.FILL; 302 gridDrawBarRightData.verticalAlignment = GridData.FILL; 303 gridDrawBarRightData.grabExcessVerticalSpace = true ; 304 this.drawBarRight.setLayoutData(gridDrawBarRightData); 305 306 309 drawNothingDrawBarItem = new ToolItem(drawBarLeft, SWT.RADIO); 311 drawNothingDrawBarItem.setToolTipText(drawNothingToolTipText); 312 drawNothingDrawBarItem.setImage(Icons.getImageRegistry().get(FileName.DRAW_NOTHING_ICON)); 313 drawLineDrawBarItem = new ToolItem(drawBarLeft, SWT.RADIO); 315 drawLineDrawBarItem.setToolTipText(drawLineToolTipText); 316 Image img = new Image(this.parent.getDisplay(), new Rectangle(15, 15, 318 15, 15)); 319 img.setBackground(this.parent.getDisplay().getSystemColor( 320 SWT.COLOR_WHITE)); 321 drawLineDrawBarItem.setImage(img); 322 GC gc = new GC(img); 323 gc.setBackground(this.parent.getDisplay().getSystemColor( 324 SWT.COLOR_WHITE)); 325 gc.setForeground(this.parent.getDisplay().getSystemColor( 326 SWT.COLOR_BLACK)); 327 gc.drawLine(0, 0, 15, 15); 328 gc.dispose(); 329 addPointDrawBarItem = new ToolItem(drawBarLeft, SWT.RADIO) ; 331 addPointDrawBarItem.setToolTipText(addPointToolTip) ; 332 addPointDrawBarItem.setImage(Icons.getImageRegistry().get(FileName.ADDPOINT_ICON)) ; 333 334 new ToolItem(drawBarLeft, SWT.SEPARATOR); 337 maximizedViewBarItem = new ToolItem(drawBarLeft, SWT.PUSH); 339 maximizedViewBarItem.setToolTipText(maximizedViewToolTipText); 340 maximizedViewBarItem.setImage(Icons.getImageRegistry().get(FileName.MAXIMIZEVIEW_ICON)); 341 342 Image imgTemp2 = new Image(this.parent.getDisplay(), new Rectangle(15, 344 15, 15, 15)); 345 GC gc2 = new GC(imgTemp2); 346 gc2.setForeground(this.parent.getDisplay().getSystemColor( 347 SWT.COLOR_BLACK)); 348 gc2.drawLine(4, 4, 11, 4); 349 gc2.drawLine(11, 4, 11, 11); 350 gc2.dispose(); 351 drawCrenelHVDrawBarItem = new ToolItem(drawBarRight, SWT.RADIO); 353 drawCrenelHVDrawBarItem.setToolTipText(drawCrenelHVToolTipText); 354 drawCrenelHVDrawBarItem.setImage(imgTemp2); 355 Image imgTemp3 = new Image(this.parent.getDisplay(), new Rectangle(15, 357 15, 15, 15)); 358 GC gc3 = new GC(imgTemp3); 359 gc3.setForeground(this.parent.getDisplay().getSystemColor( 360 SWT.COLOR_BLACK)); 361 gc3.drawLine(4, 11, 4, 4); 362 gc3.drawLine(4, 4, 11, 4); 363 gc3.dispose(); 364 drawCrenelVHDrawBarItem = new ToolItem(drawBarRight, SWT.RADIO); 365 drawCrenelVHDrawBarItem.setToolTipText(drawCrenelVHToolTipText); 366 drawCrenelVHDrawBarItem.setImage(imgTemp3); 367 368 deletePointDrawBarItem = new ToolItem(drawBarRight, SWT.RADIO) ; 370 deletePointDrawBarItem.setToolTipText(deletePointToolTip) ; 371 deletePointDrawBarItem.setImage(Icons.getImageRegistry().get(FileName.DELPOINT_ICON)) ; 372 new ToolItem(drawBarRight, SWT.SEPARATOR) ; 374 normalViewBarItem = new ToolItem(drawBarRight, SWT.PUSH); 375 normalViewBarItem.setToolTipText(normalViewToolItemText); 376 normalViewBarItem.setImage(Icons.getImageRegistry().get(FileName.NORMALVIEW_ICON)); 377 378 379 drawNothingDrawBarItem.addSelectionListener(this); 382 drawLineDrawBarItem.addSelectionListener(this); 383 maximizedViewBarItem.addSelectionListener(this); 384 normalViewBarItem.addSelectionListener(this); 385 drawCrenelHVDrawBarItem.addSelectionListener(this); 386 drawCrenelVHDrawBarItem.addSelectionListener(this); 387 addPointDrawBarItem.addSelectionListener(this) ; 388 deletePointDrawBarItem.addSelectionListener(this) ; 389 390 Menu popup = new Menu(this.drawBarLeft); 393 this.showTextDrawPopupItem = new MenuItem(popup, SWT.CHECK); 394 this.showTextDrawPopupItem.setSelection(false); 395 this.showTextDrawPopupItem.setText(showTextPopupText); 396 this.showTextDrawPopupItem.addSelectionListener(this); 398 this.drawBarLeft.setMenu(popup); 400 this.drawBarRight.setMenu(popup) ; 401 402 this.disableDrawBarItems(); 404 } 405 406 409 private void initToolBar() { 410 cat.debug("-> initToolBar"); 411 GridLayout toolBarLayout = new GridLayout(); 413 toolBarLayout.numColumns = 5; 414 this.toolBarComposite.setLayout(toolBarLayout); 415 this.toolBar = new ToolBar(this.toolBarComposite, SWT.HORIZONTAL 416 | SWT.FLAT); 417 GridData toolBarData = new GridData(); 419 toolBarData.grabExcessHorizontalSpace = true; 420 toolBarData.horizontalAlignment = GridData.FILL; 421 this.toolBar.setLayoutData(toolBarData); 422 423 426 createGroupToolBarItem = new ToolItem(toolBar, SWT.PUSH); 428 createGroupToolBarItem.setImage(Icons.getImageRegistry().get( 429 FileName.NEW_ICON)); 430 createGroupToolBarItem 431 .setToolTipText("Create a new ramp description for a behavior"); 432 433 selectionToolBarItem = new ToolItem(toolBar, SWT.DROP_DOWN); 435 selectionMenu = new Menu(this.parent.getShell(), SWT.POP_UP); 437 this.selectionMenuItems = new Hashtable (); 438 this.selectionToolBarItem.setText(selectionText); 439 this.selectionImg = new Image(this.parent.getDisplay(), new Rectangle( 440 15, 15, 15, 15)); 441 selectionToolBarItem.setImage(this.selectionImg); 442 this.initSelectGroupItems(); 444 445 this.editDescriptionToolBarItem = new ToolItem(toolBar, SWT.PUSH); 447 this.editDescriptionToolBarItem.setImage(Icons.getImageRegistry().get( 448 FileName.PASTE_ICON)); 449 this.editDescriptionToolBarItem 450 .setToolTipText(editDescriptionToolTipText); 451 452 this.deleteSelectionToolBarItem = new ToolItem(toolBar, SWT.PUSH); 454 this.deleteSelectionToolBarItem.setImage(Icons.getImageRegistry().get( 455 FileName.DELETE_ICON)); 456 this.deleteSelectionToolBarItem 457 .setToolTipText(deleteSelectionToolTipText); 458 new ToolItem(toolBar, SWT.SEPARATOR); 460 this.changeScaleToolBarItem = new ToolItem(toolBar, SWT.PUSH); 462 this.changeScaleToolBarItem.setText(changeScaleText); 463 this.changeScaleToolBarItem.setToolTipText(changeScaleToolTipText); 464 Image imgChangeScale = new Image(this.parent.getDisplay(), 465 new Rectangle(15, 15, 15, 15)); 466 GC gc = new GC(imgChangeScale); 467 gc.drawLine(3, 3, 12, 12); 468 gc.drawLine(3, 12, 12, 3); 469 gc.dispose(); 470 this.changeScaleToolBarItem.setImage(imgChangeScale); 471 472 this.addToolBarItemText(); 475 476 479 this.createGroupToolBarItem.addSelectionListener(this); 481 this.selectionToolBarItem.addSelectionListener(this); 483 this.editDescriptionToolBarItem.addSelectionListener(this); 485 this.deleteSelectionToolBarItem.addSelectionListener(this); 487 this.changeScaleToolBarItem.addSelectionListener(this); 489 490 Menu popup = new Menu(this.toolBar); 493 this.showTextPopupItem = new MenuItem(popup, SWT.CHECK); 494 this.showTextPopupItem.setSelection(true); 495 this.showTextPopupItem.setText(showTextPopupText); 496 this.showTextPopupItem.addSelectionListener(this); 498 this.toolBar.setMenu(popup); 500 501 this.deleteSelectionToolBarItem.setEnabled(false); 504 this.editDescriptionToolBarItem.setEnabled(false); 505 506 509 new Label(this.toolBarComposite, SWT.FLAT).setText(xAxisLabel); 511 this.xAxisText = new Text(this.toolBarComposite, SWT.BORDER); 512 GridData gridXAxis = new GridData(); 513 gridXAxis.horizontalAlignment = GridData.FILL; 514 this.xAxisText.setLayoutData(gridXAxis); 516 518 new Label(this.toolBarComposite, SWT.FLAT).setText(yAxisLabel); 520 this.yAxisText = new Text(this.toolBarComposite, SWT.BORDER); 521 GridData gridYAxis = new GridData(); 522 gridYAxis.horizontalAlignment = GridData.FILL; 523 this.yAxisText.setLayoutData(gridYAxis); 525 527 this.disableCoordinateEdition(); 529 } 530 531 534 private void enableCoordinateEdition() { 535 this.xAxisText.setEditable(true); 536 this.yAxisText.setEditable(true); 537 this.xAxisText.addModifyListener(this); 538 this.yAxisText.addModifyListener(this); 539 } 540 541 544 private void disableCoordinateEdition() { 545 this.xAxisText.setEditable(false); 546 this.yAxisText.setEditable(false); 547 this.xAxisText.removeModifyListener(this); 548 this.yAxisText.removeModifyListener(this); 549 } 550 551 557 private void setCoordinateEditionPoint(Point current) { 558 this.xAxisText.setText(Integer.toString(current.x)); 560 this.yAxisText.setText(Integer.toString(current.y)); 561 } 562 563 566 private void disableDrawBarItems() { 567 ToolItem[] childrenLeft = this.drawBarLeft.getItems(); 568 ToolItem[] childrenRight = this.drawBarRight.getItems(); 569 for (int i = 0; i < childrenLeft.length; i++) { 571 childrenLeft[i].setEnabled(false); 572 } 573 for (int i = 0; i < childrenRight.length; i++) { 574 childrenRight[i].setEnabled(false); 575 } 576 } 577 578 581 private void enableDrawBarItems() { 582 ToolItem[] childrenLeft = this.drawBarLeft.getItems(); 583 for (int i = 0; i < childrenLeft.length; i++) { 585 childrenLeft[i].setEnabled(true); 586 } 587 ToolItem[] childrenRight = this.drawBarRight.getItems(); 588 for (int i = 0; i < childrenRight.length; i++) { 590 childrenRight[i].setEnabled(true); 591 } 592 this.setNormalViewMode(); 594 this.drawCrenelHVDrawBarItem.setSelection(false); 596 this.drawCrenelVHDrawBarItem.setSelection(false); 597 this.drawNothingDrawBarItem.setSelection(true); 598 this.drawLineDrawBarItem.setSelection(false); 599 } 600 601 604 private void removeDrawBarItemText() { 605 cat.debug("-> removeDrawBarItemText"); 606 this.drawNothingDrawBarItem.setText(""); 607 this.drawLineDrawBarItem.setText(""); 608 this.maximizedViewBarItem.setText(""); 609 this.normalViewBarItem.setText(""); 610 this.drawCrenelHVDrawBarItem.setText("") ; 611 this.drawCrenelVHDrawBarItem.setText("") ; 612 this.addPointDrawBarItem.setText("") ; 613 this.deletePointDrawBarItem.setText("") ; 614 this.content.layout(); 616 } 617 618 621 private void addDrawBarItemText() { 622 cat.debug("-> addDrawBarItemText"); 623 this.drawNothingDrawBarItem.setText(drawNothingText); 624 this.drawLineDrawBarItem.setText(drawLineText); 625 this.maximizedViewBarItem.setText(maximizedViewText); 626 this.normalViewBarItem.setText(normalViewText); 627 this.drawCrenelHVDrawBarItem.setText(drawCrenelHVText) ; 628 this.drawCrenelVHDrawBarItem.setText(drawCrenelVHText) ; 629 this.addPointDrawBarItem.setText(addPointText) ; 630 this.deletePointDrawBarItem.setText(deletePointText) ; 631 this.content.layout(); 633 } 634 635 638 private void removeTooBarItemText() { 639 cat.debug("-> removeToolBarItemText"); 640 this.createGroupToolBarItem.setText(""); 641 this.selectionToolBarItem.setText(""); 642 this.editDescriptionToolBarItem.setText(""); 643 this.deleteSelectionToolBarItem.setText(""); 644 this.changeScaleToolBarItem.setText(""); 645 this.parent.layout(); 647 } 648 649 private void addToolBarItemText() { 650 cat.debug("-> addToolBarItemText"); 651 this.createGroupToolBarItem.setText(createGroupToolBarText); 652 this.selectionToolBarItem.setText(selectionText); 653 this.editDescriptionToolBarItem.setText(editDescriptionText); 654 this.deleteSelectionToolBarItem.setText(deleteSelectionText); 655 this.changeScaleToolBarItem.setText(changeScaleText); 656 this.parent.layout(); 658 } 659 660 667 private boolean switchSelectedGroup(Object source) { 668 cat.debug("-> switchSelectedRamp"); 669 Enumeration items = this.selectionMenuItems.keys(); 670 while (items.hasMoreElements()) { 672 Object item = items.nextElement(); 673 if (item == source) { 675 this 677 .setSelectedGroup((GroupDescription) this.selectionMenuItems 678 .get(item)); 679 return true; 680 } 681 } 682 return false; 683 } 684 685 692 public void setSelectedGroup(GroupDescription gd) { 693 cat.debug("-> setSelectedGroup"); 694 if (gd == null) { 697 GC gc = new GC(this.selectionImg); 699 gc.setBackground(this.parent.getDisplay().getSystemColor( 700 SWT.COLOR_WHITE)); 701 gc.fillRectangle(0, 0, 15, 15); 702 gc.dispose(); 703 this.selectionToolBarItem.setText(selectionText); 705 this.parent.layout(); 706 this.groupDescriptionSelected = null; 708 this.disableDrawBarItems(); 710 this.drawableCanvas.redraw(); 712 this.deleteSelectionToolBarItem.setEnabled(false); 714 this.editDescriptionToolBarItem.setEnabled(false); 715 716 return; 717 } 718
|