Example #1
0
  @Test
  public void testFindStylesByModelYearId() {

    StyleManager styleManager = (StyleManager) getManager();
    StyleResult result = styleManager.findStylesByModelYearId(modelyearid);

    for (Style style : result.getStyleHolder()) {
      System.out.format("%s\t%s\n", style.getId(), style.getName());
    }
  }
Example #2
0
  private void checkToggle() {
    TextMapElement textElement = sm.getCurrentItem();
    if (textElement != null && t.getSelection().length > 0) {
      Element parent = getParent(textElement);

      if (t.getSelection()[0].getData().equals(sm.getSemanticsTable().getKeyFromAttribute(parent))
          || (t.getSelection()[0].getData().equals("boxline") && isBoxLine(parent)))
        toggleApplyButton(true);
      else toggleApplyButton(false);
    } else toggleApplyButton(false);
  }
Example #3
0
  private Element getParent(TextMapElement item) {
    Element parent = (Element) item.n.getParent();
    while (sm.getSemanticsTable().getSemanticTypeFromAttribute(parent) == null
        || sm.getSemanticsTable().getSemanticTypeFromAttribute(parent).equals("action")) {
      parent = (Element) parent.getParent();
    }

    return parent;
  }
Example #4
0
  public void setSelection(TextMapElement item) {
    Element parent = (Element) item.n.getParent();
    String text;
    if (item instanceof BrlOnlyMapElement && isBoxLine(item.parentElement())) {
      text = "boxline";
    } else {
      while (sm.getSemanticsTable().getSemanticTypeFromAttribute(parent) == null
          || sm.getSemanticsTable().getSemanticTypeFromAttribute(parent).equals("action")) {
        parent = (Element) parent.getParent();
      }
      text = sm.getSemanticsTable().getKeyFromAttribute(parent);

      if (text.contains("local_")) {
        String[] tokens = text.split("_");
        text = tokens[1];
      }
    }

    setSelection(searchTree(text));
  }
Example #5
0
  private boolean deleteStyle() {
    LocaleHandler lh = new LocaleHandler();
    MessageBox mb = new MessageBox(group.getShell(), SWT.OK | SWT.CANCEL);
    mb.setText(lh.localValue("deleteMB"));
    mb.setMessage(lh.localValue("deleteMBMessage"));

    int open = mb.open();

    if (open == SWT.OK) {
      sm.deleteStyle((String) t.getSelection()[0].getData());
      t.remove(t.getSelectionIndex());
      return true;
    } else return false;
  }
Example #6
0
  private void populateTable(Set<String> list) {
    StylesType perefferedStyle = StylesType.valueOf("name");
    String perefferedName;

    for (String s : list) {
      if (!s.contains("local_")
          && !s.equals("document")
          && !s.equals("italicx")
          && !s.equals("boldx")
          && !s.equals("topBox")
          && !s.equals("middleBox") & !s.equals("bottomBox")
          && !s.equals("fullBox")
          && !s.equals("underlinex")
          && !s.equals("none")) {
        if (sm.getSemanticsTable().get(s).contains(perefferedStyle)) {
          perefferedName = (String) sm.getSemanticsTable().get(s).get(perefferedStyle);
          addTableItem(perefferedName, s);
        } else {
          addTableItem(s, s);
        }
      }
    }
  }
  /**
   * Set the static scene variable. This scene will be set on all CssErrors generated after the call
   * is made. The argument may be null. Null should be passed when the code exits a method from
   * which CssErrors may be created. This is intended internal use and should not be called from
   * outside the css code.
   */
  public static void setCurrentScene(Scene scene) {

    // Treat as a no-op if noone cares about CssErrors
    if (StyleManager.getErrors() == null) return;

    if (scene != null) {
      // don't make new ref for same scene
      final Scene oldScene = SCENE_REF != null ? SCENE_REF.get() : null;
      if (oldScene != scene) {
        SCENE_REF = new WeakReference<Scene>(scene);
      }
    } else {
      SCENE_REF = null;
    }
  }
Example #8
0
 @Override
 protected int drawUnselectedText(Graphics graphics, int x, int y, int p0, int p1)
     throws BadLocationException {
   Graphics2D graphics2D = (Graphics2D) graphics;
   graphics2D.setRenderingHint(
       RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
   Font saveFont = graphics.getFont();
   Color saveColor = graphics.getColor();
   SyntaxDocument doc = (SyntaxDocument) getDocument();
   Segment segment = getLineBuffer();
   try {
     Iterator<IToken> i = doc.getTokens(p0, p1);
     int start = p0;
     while (i.hasNext()) {
       IToken t = i.next();
       if (start < t.start()) {
         doc.getText(start, t.start() - start, segment);
         x = defaultStyle.drawText(segment, x, y, graphics, this, start);
       }
       int l = t.length();
       int s = t.start();
       if (s < p0) {
         l -= (p0 - s);
         s = p0;
       }
       if (s + l > p1) {
         l = p1 - s;
       }
       doc.getText(s, l, segment);
       x = manager.getStyle(t.type()).drawText(segment, x, y, graphics, this, t.start());
       start = t.start() + t.length();
     }
     if (start < p1) {
       doc.getText(start, p1 - start, segment);
       x = defaultStyle.drawText(segment, x, y, graphics, this, start);
     }
   } catch (BadLocationException e) {
   } finally {
     graphics.setFont(saveFont);
     graphics.setColor(saveColor);
   }
   return x;
 }
Example #9
0
  public StyleTable(final StyleManager sm, SashForm sash) {
    LocaleHandler lh = new LocaleHandler();
    this.sm = sm;
    this.group = new Group(sash, SWT.FILL | SWT.BORDER);
    setLayoutData(this.group, LEFT_MARGIN, RIGHT_MARGIN, TOP_MARGIN, BOTTOM_MARGIN);
    this.group.setLayout(new FormLayout());
    this.group.setVisible(false);

    Listener resizeListener =
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            checkFontSize((Button) e.widget);
          }
        };

    restoreButton = new Button(this.group, SWT.CHECK);
    restoreButton.setText(lh.localValue("restore"));
    setLayoutData(restoreButton, 1, 100, 0, 5);

    this.t = new Table(this.group, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    setLayoutData(this.t, 0, 100, 5, 90);

    TableColumn tc1 = new TableColumn(this.t, SWT.CENTER);
    tc1.setWidth(0);
    tc1.setResizable(false);

    final TableColumn tc2 = new TableColumn(this.t, SWT.CENTER);
    tc2.setText(lh.localValue("styles"));

    this.t.setLinesVisible(true);
    this.t.setHeaderVisible(true);

    newButton = new Button(this.group, SWT.NONE);
    newButton.setText(lh.localValue("new"));
    setLayoutData(newButton, 0, 25, 90, 100);
    initialFont = newButton.getFont();
    newButton.addListener(SWT.Resize, resizeListener);

    editButton = new Button(this.group, SWT.NONE);
    editButton.setText(lh.localValue("edit"));
    setLayoutData(editButton, 25, 50, 90, 100);
    editButton.addListener(SWT.Resize, resizeListener);

    deleteButton = new Button(this.group, SWT.NONE);
    deleteButton.setText(lh.localValue("delete"));
    setLayoutData(deleteButton, 50, 75, 90, 100);
    deleteButton.addListener(SWT.Resize, resizeListener);

    applyButton = new Button(this.group, SWT.NONE);
    applyButton.setText(lh.localValue("apply"));
    setLayoutData(applyButton, 75, 100, 90, 100);
    applyButton.addListener(SWT.Resize, resizeListener);

    group.pack();
    Control[] tabList = {t, newButton, editButton, deleteButton, applyButton, restoreButton};
    group.setTabList(tabList);

    tc2.setWidth(group.getClientArea().width);

    t.getHorizontalBar().dispose();

    this.group.addListener(
        SWT.Resize,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            tc2.setWidth(group.getClientArea().width);
          }
        });

    this.t.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (!traverseFired && Character.isLetter(e.character)) {
              int loc = searchTree(e.character);
              if (loc != -1) setSelection(loc);
            } else if (e.keyCode == SWT.CR) {
              sm.apply((String) t.getSelection()[0].getData());
              traverseFired = false;
            } else traverseFired = false;
          }
        });

    t.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            checkToggle();
          }
        });

    applyStyle =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            sm.apply((String) t.getSelection()[0].getData());
            checkToggle();
          }
        };

    removeStyle =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            sm.remove((String) t.getSelection()[0].getData());
            checkToggle();
          }
        };

    populateTable(sm.getKeySet());
    initializeListeners();
    traverseFired = false;
    sort();
  }
Example #10
0
 public void resetTable(String configFile) {
   t.removeAll();
   populateTable(sm.getKeySet());
   sort();
 }