public void createControl(Composite parent) {
    viewer = new GalleryViewer();

    EditDomain editDomain = new EditDomain();
    editDomain.installTool(GEF.TOOL_SELECT, new TemplateGallerySelectTool());
    viewer.setEditDomain(editDomain);

    Properties properties = viewer.getProperties();
    properties.set(GalleryViewer.Horizontal, Boolean.TRUE);
    properties.set(GalleryViewer.Wrap, Boolean.TRUE);
    properties.set(GalleryViewer.TitlePlacement, GalleryViewer.TITLE_BOTTOM);
    properties.set(GalleryViewer.SingleClickToOpen, Boolean.TRUE);
    properties.set(GalleryViewer.SolidFrames, true);
    properties.set(GalleryViewer.FlatFrames, true);
    properties.set(GalleryViewer.ImageConstrained, true);
    properties.set(GalleryViewer.ImageStretched, true);
    properties.set(
        GalleryViewer.Layout,
        new GalleryLayout(
            GalleryLayout.ALIGN_CENTER,
            GalleryLayout.ALIGN_TOPLEFT,
            10,
            10,
            new Insets(5, 15, 5, 15)));
    properties.set(GalleryViewer.FrameContentSize, new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
    properties.set(GalleryViewer.ContentPaneBorderWidth, 1);
    properties.set(GalleryViewer.ContentPaneBorderColor, ColorUtils.getColor("#cccccc"));

    Control control = viewer.createControl(parent);
    control.setBackground(parent.getBackground());
    control.setForeground(parent.getForeground());

    viewer.setLabelProvider(new TemplateLabelProvider());

    viewer.setInput(getViewerInput());

    viewer.addOpenListener(
        new IOpenListener() {
          public void open(OpenEvent event) {
            if (normalOrEditMode) {
              if (!templateOpening) handleTemplateSelected(event.getSelection());
            }
          }
        });

    MindMapUI.getResourceManager().addResourceManagerListener(this);

    setControl(control);
  }
Пример #2
0
  private void doSaveNotes() {
    INotesContent html = notesAdapter.makeNewHtmlContent();
    INotesContent plain = notesAdapter.makeNewPlainContent();
    ITopic topic = topicPart.getTopic();
    EditDomain domain = topicPart.getSite().getViewer().getEditDomain();
    if (domain != null) {
      ICommandStack cs = domain.getCommandStack();
      if (cs != null) {
        ModifyNotesCommand modifyHtml = new ModifyNotesCommand(topic, html, INotes.HTML);
        ModifyNotesCommand modifyPlain = new ModifyNotesCommand(topic, plain, INotes.PLAIN);
        CompoundCommand cmd = new CompoundCommand(modifyHtml, modifyPlain);
        cmd.setLabel(CommandMessages.Command_ModifyNotes);
        cs.execute(cmd);
        return;
      }
    }

    INotes notes = topic.getNotes();
    notes.setContent(INotes.HTML, html);
    notes.setContent(INotes.PLAIN, plain);
  }