示例#1
0
  public final void execute(
      final int keyLength,
      final int keyPos,
      final int overlayIndex,
      final boolean resetShift,
      final boolean executeCalc,
      final boolean whichTab,
      final boolean activateOverlay) {
    if (keyLength > 0) {
      if (keyLength == 1) {
        button3.setSelection(true);
        button4.setSelection(false);
      } else {
        button3.setSelection(false);
        button4.setSelection(true);
      }
      polyOnOffSelected(null);

      spinner1.setSelection(keyLength);
      changedVigOptions();
      if (keyPos < 0) {
        text = getEditorText();
        recalcGraph();
      }
    }
    if (keyPos > -1) {
      spinner2.setSelection(keyPos);
      changedVigOptions();
      text = getEditorText();
      recalcGraph();
    }

    if (overlayIndex > -1 && overlayIndex < combo1.getVisibleItemCount() - 1) {
      combo1.select(overlayIndex);
    }

    if (resetShift) {
      myGraph.getFrequencyGraph().resetDrag();
    }
    if (executeCalc) {
      if (checkEditor()) {
        text = getEditorText();
        selectAppropriateAlphabet();
        recalcGraph();
      }
    }

    if (whichTab) {
      tabFolder1.setSelection(0);
    } else {
      tabFolder1.setSelection(1);
    }

    btnReferenceTools.setSelection(activateOverlay);
    myGraph.setOverlayActivated(btnReferenceTools.getSelection());
    myGraph.redraw();
  }
示例#2
0
 @Test
 public void testPreserveValues() {
   Combo combo = new Combo(shell, SWT.READ_ONLY);
   Fixture.markInitialized(display);
   // Test preserving a combo with no items and (naturally) no selection
   Fixture.preserveWidgets();
   WidgetAdapter adapter = WidgetUtil.getAdapter(combo);
   String[] items = ((String[]) adapter.getPreserved(PROP_ITEMS));
   assertEquals(0, items.length);
   assertEquals(new Integer(-1), adapter.getPreserved(PROP_SELECTION_INDEX));
   assertNull(adapter.getPreserved(ComboLCA.PROP_TEXT_LIMIT));
   Object visibleItemCount = adapter.getPreserved(ComboLCA.PROP_VISIBLE_ITEM_COUNT);
   assertEquals(new Integer(combo.getVisibleItemCount()), visibleItemCount);
   assertEquals(Boolean.FALSE, adapter.getPreserved(ComboLCA.PROP_EDITABLE));
   assertEquals(new Point(0, 0), adapter.getPreserved(ComboLCA.PROP_SELECTION));
   // Test preserving combo with items were one is selected
   Fixture.clearPreserved();
   combo.add("item 1");
   combo.add("item 2");
   combo.select(1);
   combo.setListVisible(true);
   SelectionListener selectionListener = new SelectionAdapter() {};
   combo.addSelectionListener(selectionListener);
   combo.addModifyListener(
       new ModifyListener() {
         public void modifyText(ModifyEvent event) {}
       });
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(combo);
   items = ((String[]) adapter.getPreserved(PROP_ITEMS));
   assertEquals(2, items.length);
   assertEquals("item 1", items[0]);
   assertEquals("item 2", items[1]);
   assertEquals(new Integer(1), adapter.getPreserved(PROP_SELECTION_INDEX));
   visibleItemCount = adapter.getPreserved(ComboLCA.PROP_VISIBLE_ITEM_COUNT);
   assertEquals(new Integer(combo.getVisibleItemCount()), visibleItemCount);
   assertEquals("item 2", adapter.getPreserved(Props.TEXT));
   assertEquals(Boolean.FALSE, adapter.getPreserved(ComboLCA.PROP_EDITABLE));
   Fixture.clearPreserved();
   // foreground background font
   Color background = new Color(display, 122, 33, 203);
   combo.setBackground(background);
   Color foreground = new Color(display, 211, 178, 211);
   combo.setForeground(foreground);
   Font font = new Font(display, "font", 12, SWT.BOLD);
   combo.setFont(font);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(combo);
   assertEquals(background, adapter.getPreserved(Props.BACKGROUND));
   assertEquals(foreground, adapter.getPreserved(Props.FOREGROUND));
   assertEquals(font, adapter.getPreserved(Props.FONT));
   Fixture.clearPreserved();
   // tooltiptext
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(combo);
   assertEquals(null, combo.getToolTipText());
   Fixture.clearPreserved();
   combo.setToolTipText("some text");
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(combo);
   assertEquals("some text", combo.getToolTipText());
   Fixture.clearPreserved();
 }