public Image getColumnImage(Object element, int columnIndex) {
      DatabaseQuerySettingsStructure.DataMapping mapping =
          (DatabaseQuerySettingsStructure.DataMapping) element;

      if (columnIndex == 0) {
        return org.eclipse.vtp.desktop.core.Activator.getDefault()
            .getImageRegistry()
            .get("ICON_TINY_SQUARE");
      } else if (columnIndex == 1) {
        if (mapping.mappingType == 1) {
          return org.eclipse.vtp.desktop.core.Activator.getDefault()
              .getImageRegistry()
              .get("ICON_DOMAIN");
        }
      }

      return null;
    }
 /**
  * Creates a new instance that represents the given ui element.
  *
  * @param uiElement The ui element this frame represents
  */
 public MantisElementFrame(IDesignElement uiElement) {
   super(uiElement);
   this.uiElement = uiElement;
   uiElement.addListener(this);
   uiElement.addPropertyListener(this);
   if (uiElement.getIcon() != null) icon = uiElement.getIcon();
   else
     icon =
         org.eclipse.vtp.desktop.core.Activator.getDefault().getImageRegistry().get("ICON_MODULE");
 }
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
  */
 public Image getColumnImage(Object element, int columnIndex) {
   VariableDeclaration vd = (VariableDeclaration) element;
   if (columnIndex == 0 && vd.isSecure())
     return Activator.getDefault().getImageRegistry().get("ICON_LOCK");
   return null;
 }
  /* (non-Javadoc)
   * @see org.eclipse.vtp.desktop.editors.core.elements.PrimitivePropertiesPanel#createControls(org.eclipse.swt.widgets.Composite)
   */
  public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(2, false));
    parent.setBackgroundMode(SWT.INHERIT_DEFAULT);

    Composite nameComp = new Composite(parent, SWT.NONE);
    nameComp.setBackground(parent.getBackground());
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    nameComp.setLayoutData(gd);
    nameComp.setLayout(new GridLayout(2, false));

    Label nameLabel = new Label(nameComp, SWT.NONE);
    nameLabel.setText("Entry Name:");
    nameLabel.setLayoutData(new GridData());
    nameText = new Text(nameComp, SWT.BORDER | SWT.SINGLE);
    nameText.setText(getElement().getName());
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label defaultBrandLabel = new Label(nameComp, SWT.NONE);
    defaultBrandLabel.setText("Default Brand");
    defaultBrandLabel.setLayoutData(new GridData());
    defaultBrandCombo = new Combo(nameComp, SWT.READ_ONLY | SWT.DROP_DOWN);
    defaultBrandCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    for (IBrand b : brands) {
      defaultBrandCombo.add(getLabel(b));
    }
    String currentDefault =
        ((BeginInformationProvider) ((PrimitiveElement) getElement()).getInformationProvider())
            .getDefaultBrand();
    for (int i = 0; i < brands.size(); i++) {
      if (brands.get(i).getId().equals(currentDefault)) {
        defaultBrandCombo.select(i);
        break;
      }
    }
    if (defaultBrandCombo.getSelectionIndex() == -1) defaultBrandCombo.select(0);

    Table variableTable = new Table(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
    variableTable.setHeaderVisible(true);

    TableColumn secureColumn = new TableColumn(variableTable, SWT.NONE);
    secureColumn.setImage(Activator.getDefault().getImageRegistry().get("ICON_LOCK"));
    secureColumn.setAlignment(SWT.CENTER);
    secureColumn.setWidth(23);

    TableColumn nameColumn = new TableColumn(variableTable, SWT.NONE);
    nameColumn.setText("Variable Name");
    nameColumn.setWidth(150);

    TableColumn typeColumn = new TableColumn(variableTable, SWT.NONE);
    typeColumn.setText("Type");
    typeColumn.setWidth(150);

    TableColumn valueColumn = new TableColumn(variableTable, SWT.NONE);
    valueColumn.setText("Value");
    valueColumn.setWidth(200);

    gd = new GridData(GridData.FILL_BOTH);
    gd.verticalSpan = 2;
    gd.widthHint = 505;
    gd.heightHint = 200;
    variableTable.setLayoutData(gd);
    valueEditor = new TextCellEditor(variableTable);
    secureEditor = new CheckboxCellEditor(variableTable);
    variableViewer = new TableViewer(variableTable);
    variableViewer.setColumnProperties(new String[] {"Secure", "Name", "Type", "Value"});
    variableViewer.setCellEditors(new CellEditor[] {secureEditor, null, null, valueEditor});
    variableViewer.setCellModifier(new ValueCellModifier());
    variableViewer.setContentProvider(new VariableContentProvider());
    variableViewer.setLabelProvider(new VariableLabelProvider());
    variableViewer.setInput(this);
    variableViewer.setComparator(
        new ViewerComparator() {

          @Override
          public int compare(Viewer viewer, Object e1, Object e2) {
            VariableDeclaration v1 = (VariableDeclaration) e1;
            VariableDeclaration v2 = (VariableDeclaration) e2;
            return v1.getName().compareTo(v2.getName());
          }
        });
    variableViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            removeButton.setEnabled(!event.getSelection().isEmpty());
          }
        });
    variableViewer
        .getControl()
        .addKeyListener(
            new KeyListener() {
              public void keyPressed(KeyEvent e) {}

              public void keyReleased(KeyEvent e) {
                if (e.keyCode == SWT.DEL || e.keyCode == SWT.BS) removeVariable();
              }
            });
    Composite buttonComp = new Composite(parent, SWT.NONE);
    buttonComp.setLayout(new GridLayout(1, false));
    buttonComp.setLayoutData(new GridData());
    addButton = new Button(buttonComp, SWT.PUSH);
    addButton.setText("Add");
    addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addButton.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            List<String> reservedNames = new ArrayList<String>();
            for (VariableDeclaration vd : declarations) {
              reservedNames.add(vd.getName());
            }
            NewVariableDialog nvd =
                new NewVariableDialog(
                    addButton.getShell(),
                    reservedNames,
                    getElement().getDesign().getDocument().getProject().getBusinessObjectSet());

            if (nvd.open() == SWT.OK) {
              declarations.add(new VariableDeclaration(nvd.name, nvd.type, 0, null, nvd.secure));
              updateVariables();
            }
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    removeButton = new Button(buttonComp, SWT.PUSH);
    removeButton.setText("Remove");
    removeButton.setEnabled(false);
    removeButton.setLayoutData(new GridData());
    removeButton.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            removeVariable();
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
  }
  /* (non-Javadoc)
   * @see org.eclipse.vtp.desktop.editors.themes.mantis.MantisComponentFrame#renderFrame(org.eclipse.swt.graphics.GC, int, int, java.util.Map)
   */
  public void renderFrame(GC gc, int renderingPhase, int options, Map<String, Object> resourceMap) {
    Font originalFont = gc.getFont();
    Color foreground = gc.getForeground();
    Color background = gc.getBackground();
    Color selectedColor = getColor(gc, resourceMap, "rust.selection.color", 82, 140, 55);
    Color elementBlue = getColor(gc, resourceMap, "rust.element.color", 207, 234, 195);
    Color elementGradBlue = getColor(gc, resourceMap, "rust.element.color.gradient", 161, 211, 137);
    Font nameFont = new Font(gc.getDevice(), "Arial", 10, SWT.NORMAL);
    gc.setFont(nameFont);
    if (upperLeft == null) {
      initializeGraphics(gc, resourceMap);
    }
    int width = lowerRight.x - upperLeft.x;
    int height = lowerRight.y - upperLeft.y;
    int mainBodyHeight = height - (uiElement.hasConnectors() ? 12 : 0);

    if (uiElement.hasConnectors()) {
      // draw inspector tray
      gc.setBackground(elementBlue);
      gc.fillRoundRectangle(upperLeft.x, upperLeft.y + 3, width - 1, height - 3, 20, 20);

      // draw inspector tray border
      if (selected && (options & Theme.RENDER_FLAG_NO_SELECTION) == 0) {
        gc.setForeground(selectedColor);
      }
      gc.drawRoundRectangle(upperLeft.x, upperLeft.y + 3, width - 1, height - 3, 20, 20);
    }

    // draw main body
    gc.setBackground(elementBlue);
    gc.fillRoundRectangle(upperLeft.x, upperLeft.y, width - 1, mainBodyHeight - 1, 20, 20);
    gc.setBackground(elementGradBlue);
    gc.fillRoundRectangle(
        upperLeft.x + 1,
        upperLeft.y + (mainBodyHeight / 2) - 1,
        lowerRight.x - upperLeft.x - 2,
        (mainBodyHeight / 2) + (mainBodyHeight % 2),
        20,
        20);
    //		gc.setForeground(elementBlue);
    //		gc.fillGradientRectangle(upperLeft.x + 2,
    //			upperLeft.y
    //			+ (mainBodyHeight / 3),
    //			lowerRight.x - upperLeft.x - 4,
    //			((mainBodyHeight / 3) * 2) - 5,
    //			true);
    gc.setForeground(foreground);
    gc.setBackground(background);

    // draw main body border
    if (selected && (options & Theme.RENDER_FLAG_NO_SELECTION) == 0) {
      gc.setForeground(selectedColor);
    }
    gc.drawRoundRectangle(upperLeft.x, upperLeft.y, width - 1, mainBodyHeight - 1, 20, 20);

    gc.setForeground(foreground);
    // draw connector hot spot
    if (uiElement.hasConnectors()) {
      gc.drawLine(lowerRight.x - 19, lowerRight.y - 8, lowerRight.x - 5, lowerRight.y - 8);
      //			gc.drawLine(lowerRight.x - 8, lowerRight.y - 15, lowerRight.x - 3, lowerRight.y - 10);
      gc.drawLine(lowerRight.x - 10, lowerRight.y - 3, lowerRight.x - 5, lowerRight.y - 8);
    }

    // draw icon
    if ((options & Theme.RENDER_FLAG_NO_ICONS) == 0) {
      gc.drawImage(
          icon,
          upperLeft.x + 5,
          upperLeft.y + (((mainBodyHeight - 16) / 2) + ((mainBodyHeight - 16) % 2)));
    }

    // draw element name
    int curX = upperLeft.x + 25;
    int curY = upperLeft.y + 5;
    String[] parts = this.getDesignElement().getName().split(" ");
    Point stringExtent = gc.stringExtent(parts[0]);
    int ew = stringExtent.x;
    gc.drawString(parts[0], curX, curY, true);
    curX += stringExtent.x;
    for (int i = 1; i < parts.length; i++) {
      stringExtent = gc.stringExtent(" " + parts[i]);
      boolean wrapped = false;
      if (ew + stringExtent.x > 110) // wrap it
      {
        stringExtent = gc.stringExtent(parts[i]);
        ew = stringExtent.x;
        curY += 2 + stringExtent.y;
        curX = upperLeft.x + 25;
        wrapped = true;
      } else ew += stringExtent.x;
      gc.drawString((wrapped ? "" : " ") + parts[i], curX, curY, true);
      curX += stringExtent.x;
    }

    // draw decorator icons
    if ((options & Theme.RENDER_FLAG_NO_MARKERS) == 0) {
      if (uiElement.hasErrors())
        gc.drawImage(
            org.eclipse.vtp.desktop.core.Activator.getDefault()
                .getImageRegistry()
                .get("ICON_ERROR"),
            lowerRight.x - 17,
            upperLeft.y);
      else if (uiElement.hasWarnings())
        gc.drawImage(
            org.eclipse.vtp.desktop.core.Activator.getDefault()
                .getImageRegistry()
                .get("ICON_WARNING"),
            lowerRight.x - 16,
            upperLeft.y);
      else if (uiElement.hasTodo())
        gc.drawImage(
            org.eclipse.vtp.desktop.core.Activator.getDefault().getImageRegistry().get("ICON_TASK"),
            lowerRight.x - 18,
            upperLeft.y + 2);
    }

    // resource cleanup
    if (selected) {
      gc.setForeground(foreground);
    }
    gc.setFont(originalFont);
    nameFont.dispose();
  }
  /* (non-Javadoc)
   * @see org.eclipse.vtp.desktop.editors.themes.attraction.AttractionComponentFrame#renderFrame(org.eclipse.swt.graphics.GC, int, int, java.util.Map)
   */
  public void renderFrame(GC gc, int renderingPhase, int options, Map<String, Object> resourceMap) {
    Font originalFont = gc.getFont();
    Color foreground = gc.getForeground();
    Color background = gc.getBackground();
    Color selectedColor = getColor(gc, resourceMap, "attraction.selection.color", 0, 0, 255);
    Color elementBlue = getColor(gc, resourceMap, "attraction.element.color", 201, 229, 255);
    Color elementGradBlue =
        getColor(gc, resourceMap, "attraction.element.color.gradient", 153, 206, 255);
    Font nameFont = getFont(gc, resourceMap, "attraction.element.font", "Arial", 10, SWT.NORMAL);
    gc.setFont(nameFont);

    if (upperLeft == null) {
      initializeGraphics(gc, resourceMap);
    }
    int width = lowerRight.x - upperLeft.x;
    int height = lowerRight.y - upperLeft.y;

    gc.setBackground(elementBlue);
    gc.fillRoundRectangle(upperLeft.x, upperLeft.y, width - 1, height - 1, 12, 12);
    if ((options & Theme.RENDER_FLAG_PRINTING) == 0) {
      gc.setBackground(elementGradBlue);
      gc.fillRoundRectangle(
          upperLeft.x,
          upperLeft.y + ((lowerRight.y - upperLeft.y) / 2),
          lowerRight.x - upperLeft.x,
          ((lowerRight.y - upperLeft.y) / 2),
          12,
          12);
      gc.setForeground(elementBlue);
      gc.fillGradientRectangle(
          upperLeft.x,
          upperLeft.y + ((lowerRight.y - upperLeft.y) / 3),
          lowerRight.x - upperLeft.x,
          (((lowerRight.y - upperLeft.y) / 3) * 2) - 5,
          true);
    }
    gc.setForeground(foreground);
    gc.setBackground(background);

    // draw connector hot spot
    if (uiElement.hasConnectors()) {
      gc.drawLine(lowerRight.x - 17, lowerRight.y - 10, lowerRight.x - 3, lowerRight.y - 10);
      gc.drawLine(lowerRight.x - 8, lowerRight.y - 15, lowerRight.x - 3, lowerRight.y - 10);
      gc.drawLine(lowerRight.x - 8, lowerRight.y - 5, lowerRight.x - 3, lowerRight.y - 10);
    }

    if (selected && (options & Theme.RENDER_FLAG_NO_SELECTION) == 0) {
      gc.setForeground(selectedColor);
    }
    gc.drawRoundRectangle(upperLeft.x, upperLeft.y, width - 1, height - 1, 12, 12);
    if ((options & Theme.RENDER_FLAG_NO_ICONS) == 0) {
      gc.drawImage(icon, upperLeft.x + 10, upperLeft.y + 12);
    }
    int curX = upperLeft.x + 30;
    int curY = upperLeft.y + 15;
    String[] parts = this.getDesignElement().getName().split(" ");
    Point stringExtent = gc.stringExtent(parts[0]);
    int ew = stringExtent.x;
    gc.drawString(parts[0], curX, curY, true);
    curX += stringExtent.x;
    for (int i = 1; i < parts.length; i++) {
      stringExtent = gc.stringExtent(" " + parts[i]);
      boolean wrapped = false;
      if (ew + stringExtent.x > 110) // wrap it
      {
        stringExtent = gc.stringExtent(parts[i]);
        ew = stringExtent.x;
        curY += 3 + stringExtent.y;
        curX = upperLeft.x + 30;
        wrapped = true;
      } else ew += stringExtent.x;
      gc.drawString((wrapped ? "" : " ") + parts[i], curX, curY, true);
      curX += stringExtent.x;
    }
    if (selected) {
      gc.setForeground(foreground);
    }
    gc.setFont(originalFont);
    if ((options & Theme.RENDER_FLAG_NO_MARKERS) == 0) {
      if (uiElement.hasErrors())
        gc.drawImage(
            org.eclipse.vtp.desktop.core.Activator.getDefault()
                .getImageRegistry()
                .get("ICON_ERROR"),
            lowerRight.x - 17,
            upperLeft.y);
      else if (uiElement.hasWarnings())
        gc.drawImage(
            org.eclipse.vtp.desktop.core.Activator.getDefault()
                .getImageRegistry()
                .get("ICON_WARNING"),
            lowerRight.x - 16,
            upperLeft.y);
      else if (uiElement.hasTodo())
        gc.drawImage(
            org.eclipse.vtp.desktop.core.Activator.getDefault().getImageRegistry().get("ICON_TASK"),
            lowerRight.x - 18,
            upperLeft.y + 2);
    }
  }