コード例 #1
0
 /** @see org.eclipse.jface.viewers.IColorProvider#getForeground(Object) */
 public Color getForeground(Object element) {
   PaletteEntry entry = (PaletteEntry) element;
   if (!entry.isVisible() || !entry.getParent().isVisible()) {
     return ColorConstants.gray;
   }
   return null;
 }
コード例 #2
0
  /**
   * Creates {@code ToolEntry}.
   *
   * @param paletteRoot the {@code PaletteRoot} entry
   * @return the {@code PaletteContainer} instance
   */
  private static void createControlGroup(PaletteRoot paletteRoot) {
    PaletteGroup controlGroup = new PaletteGroup("Components");

    /* Group for storing all the <code>PaletteEntry</code> */
    List<PaletteEntry> entries = new ArrayList<PaletteEntry>();

    /* Selection tool */
    PaletteEntry entry = new SelectionToolEntry();
    entries.add(entry);
    paletteRoot.setDefaultEntry((ToolEntry) entry);

    /* Marquee tool */
    entry = new MarqueeToolEntry();
    entries.add(entry);

    /* Separate the palette */
    entry = new PaletteSeparator("org.neclipse.gef.struts2editor.ui.editor.palette.sep1");
    entry.setUserModificationPermission(PaletteEntry.PERMISSION_NO_MODIFICATION);
    entries.add(entry);

    /* Tool Entry for Result connection creation */
    entry =
        new ConnectionCreationToolEntry(
            "Result Connection",
            "Connect to Struts 2 Results",
            new SimpleFactory(S2ResultConnection.class),
            S2EditorUI.getImageDescriptor("icons/connection16.gif"),
            S2EditorUI.getImageDescriptor("icons/connection24.gif"));
    entries.add(entry);

    /* Tool Entry for Extends connection creation */
    entry =
        new ConnectionCreationToolEntry(
            "Extends Connection",
            "Connect to Struts 2 Package",
            new SimpleFactory(S2ExtendsConnection.class),
            S2EditorUI.getImageDescriptor("icons/connection16.gif"),
            S2EditorUI.getImageDescriptor("icons/connection24.gif"));
    entries.add(entry);

    /* Tool Entry for Extends connection creation */
    entry =
        new ConnectionCreationToolEntry(
            "Comment Connection",
            "Connect to Struts 2 Comment",
            new SimpleFactory(Object.class),
            S2EditorUI.getImageDescriptor("icons/connection16.gif"),
            S2EditorUI.getImageDescriptor("icons/connection24.gif"));
    entries.add(entry);

    controlGroup.addAll(entries);
    paletteRoot.add(controlGroup);
  }
コード例 #3
0
 /** @see org.eclipse.jface.viewers.ILabelProvider#getImage(Object) */
 public Image getImage(Object element) {
   PaletteEntry entry = (PaletteEntry) element;
   ImageDescriptor descriptor = entry.getSmallIcon();
   if (descriptor == null) {
     if (entry instanceof PaletteContainer) {
       descriptor = InternalImages.DESC_FOLDER_OPEN;
     } else if (entry instanceof PaletteSeparator) {
       descriptor = InternalImages.DESC_SEPARATOR;
     } else {
       return null;
     }
   }
   return getCachedImage(descriptor);
 }
コード例 #4
0
  protected Combo createGroupText(Composite panel, PaletteEntry entry) throws Exception {
    PaletteContainer container = entry.getParent();
    Combo group = new Combo(panel, SWT.SINGLE);
    String[] favoriteGroupNames = PaletteBuilder.getInstance().getFavoriteGroupNames();
    group.setItems(favoriteGroupNames);
    String label = getEntry().getParent().getLabel();
    List groups = Arrays.asList(favoriteGroupNames);
    String current = entry.getParent().getLabel();
    if (groups.contains(current)) {
      group.select(groups.indexOf(label));
    }

    group.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            handleGroupChanged(((Combo) e.getSource()).getText());
          }
        });
    return group;
  }