Package org.eclipse.gef.palette

Examples of org.eclipse.gef.palette.PaletteRoot


  /**
   * @generated
   */
  protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) {
    PaletteRoot root = super.createPaletteRoot(existingPaletteRoot);
    new OntoUML.diagram.part.OntoUMLPaletteFactory().fillPalette(root);
    return root;
  }
View Full Code Here


      //$ANALYSIS-IGNORE
      logger.fine("Root palette created");
    }
    PaletteGroup group = new PaletteGroup("creation tools");
    group.add(stackPalette);
    PaletteRoot rootPalette = new PaletteRoot();
    rootPalette.add(group);
    return rootPalette;
  }
View Full Code Here

        return categories;
     }

     public static PaletteRoot createPalette() {
        PaletteRoot paletteRoot = new PaletteRoot();
        paletteRoot.addAll(createCategories(paletteRoot));
        return paletteRoot;
     }
View Full Code Here

     * @param domain
     * @param domain The domain (ie MapEditor or MapPart) for which we are tacking tools
     * @return PaletteRoot suitable for use with a PaletteView
     */
    public static PaletteRoot createPalette() {
        PaletteRoot root = new PaletteRoot();
        IToolManager toolManager = ApplicationGIS.getToolManager();

        List<PaletteContainer> categories = new ArrayList<PaletteContainer>();

        // Normal GEF Tools (SelectionTool etc...)
        // PaletteContainer controlGroup = createControlGroup(root);
        // categories.add(controlGroup);
        PaletteToolbar navigation = new PaletteToolbar("Navigation");
//        navigation.setInitialState(PaletteDrawer.INITIAL_STATE_OPEN);
//        navigation.setDrawerType(ToolEntry.PALETTE_TYPE_TOOL);
        navigation.setUserModificationPermission(PaletteContainer.PERMISSION_NO_MODIFICATION);
//        navigation.setShowDefaultIcon(false);
       
        for( ModalToolCategory category : toolManager.getModalToolCategories() ) {

            // Simple PaletteDrawer (no icon for the tool category at this time)
            String shortcut = shortcut(category.getName());
            String name = fixLabel(category.getName());
           
            PaletteContainer container;
            if( category.getId().equals("org.locationtech.udig.tool.category.zoom") ||
                    category.getId().equals("org.locationtech.udig.tool.category.pan")){
                container = navigation;
            }
            else {
                PaletteDrawer drawer = new PaletteDrawer(name);
                drawer.setId( category.getId() );
                if( category == toolManager.getActiveCategory()){
                    drawer.setInitialState(PaletteDrawer.INITIAL_STATE_OPEN);
                }
                else {
                    drawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
                }
                drawer.setDrawerType(ToolEntry.PALETTE_TYPE_TOOL);
                drawer.setUserModificationPermission(PaletteContainer.PERMISSION_NO_MODIFICATION);
                drawer.setShowDefaultIcon(false);
                if( shortcut != null ){
                    drawer.setDescription( "("+shortcut+")" );
                }
                container = drawer;
            }
            category.container( container ); // hook up so container can cycle tools on keypress
            for( ModalItem modalItem : category ) {
                String label = fixLabel(modalItem.getName());
                String keypress = shortcut(modalItem.getName());
                ToolEntry tool = new MapToolEntry(label, modalItem, keypress, category.getId());
               
                //set the default tool
                if(modalItem.getId().equals(DEFAULT_ID)){
                    root.setDefaultEntry(tool);
                }        
                container.add(tool);
            }
            if( container == navigation){
                continue; // don't add navigation container multiple times
            }
            categories.add(container);
        }
       
        Comparator<PaletteContainer> sorter = new Comparator<PaletteContainer>(){
            List<String> preferredOrder = Arrays.asList(new String[]{
                    "org.locationtech.udig.tool.category.zoom",
                    "org.locationtech.udig.tool.category.pan",
                    "org.locationtech.udig.tool.category.info",
                    "org.locationtech.udig.tool.category.selection"
            });
            int order( String id ){
                int index = preferredOrder.indexOf(id);
                if ("Other".equals(id)) {
                    // Other will be -2 after everything else
                    return -2;
                }
                else if (index == -1 ){
                    return -1;
                }
                else {
                    // make this a positive experience with "zoom" showing up first
                    return 100-index;
                }
            }
           
            public int compare( PaletteContainer o1, PaletteContainer o2 ) {
                String s1 = o1.getId();
                String s2 = o2.getId();
                int order1 = order(s1);
                int order2 = order(s2);
               
                if ( order1 == order2){
                    return 0;
                }
                else if (order1 < order2){
                    return 1;
                }
                else {
                    return -1;
                }
                // return order1-order2; // is this the fast way? I am not good a C
            }
        };
        Collections.sort(categories,sorter );
        categories.add(0,navigation);
        // try and prevent tool category order from changing
        root.setUserModificationPermission( PaletteContainer.PERMISSION_NO_MODIFICATION );
        root.setChildren(categories);
        return root;
    }
View Full Code Here

   */
  public void createPartControl(Composite parent) {
    viewer = new PaletteViewer();
    viewer.createControl(parent);
   
    PaletteRoot root = new PaletteRoot();
   
    String[] category = getCategories();
    for(int i=0;i<category.length;i++){
      PaletteDrawer group = new PaletteDrawer(category[i]);
      IPaletteItem[] items = getPaletteItems(category[i]);
      for(int j=0;j<items.length;j++){
        HTMLPaletteEntry entry = new HTMLPaletteEntry(items[j].getLabel(),null,items[j].getImageDescriptor());
        tools.put(entry,items[j]);
        group.add(entry);
      }
      root.add(group);
    }
   
    viewer.setPaletteRoot(root);
   
    viewer.addPaletteListener(new PaletteListener(){
View Full Code Here

    return super.getAdapter(type);
  }

  @Override
  protected PaletteRoot getPaletteRoot() {
    PaletteRoot root = new PaletteRoot();

    PaletteGroup manipGroup = new PaletteGroup("Manipulate elements");
    root.add(manipGroup);

    PanningSelectionToolEntry selectionToolEntry = new PanningSelectionToolEntry();
    manipGroup.add(selectionToolEntry);

    MarqueeToolEntry marqueeToolEntry = new MarqueeToolEntry();
    manipGroup.add(marqueeToolEntry);

    PanningToolEntry panningToolEntry = new PanningToolEntry();
    manipGroup.add(panningToolEntry);

    PaletteSeparator sep2 = new PaletteSeparator();
    root.add(sep2);

    PaletteGroup instGroup = new PaletteGroup("Create elements");
    root.add(instGroup);

    instGroup.add(createPolylineToolEntry());
    instGroup.add(createRectangleToolEntry());
    instGroup.add(createEllipseToolEntry());

    root.setDefaultEntry(selectionToolEntry);

    return root;
  }
View Full Code Here

   */
  protected void unhookControl() {
//    PDPlugin.getDefault().getPluginPreferences()
//        .removePropertyChangeListener(listener);
    // remove palette model change listener
    PaletteRoot root = getPaletteRoot();
    if (root instanceof DesignerPaletteRoot) {
      if (_customizer != null){
        _customizer.setPaletteRoot(null);
      }
      IPaletteItemManager imanager = ((DesignerPaletteRoot) root)
View Full Code Here

        if (_paletteViewerPage == null) {
            DefaultEditDomain editDomain = getEditDomain();
//            PaletteItemManager manager = PaletteItemManager
//                    .getInstance(getCurrentFile(getEditorInput()));
//            manager.reset();
            PaletteRoot paletteRoot = getPaletteRoot();
            editDomain.setPaletteRoot(paletteRoot);
           
//            _paletteViewerPage = (PaletteViewerPage) super.getAdapter(PalettePage.class);
            // if possible, try to use the
            if (_paletteViewerPage == null)
View Full Code Here

  }

  public PaletteRoot getPaletteRoot() {
    if (null == _paletteRoot) {
      // create root
      _paletteRoot = new PaletteRoot();
      final List<PaletteContainer> categories = new ArrayList<PaletteContainer>();
      // a group of default control tools
      final PaletteGroup controls = new PaletteGroup(Messages.MapPalette_Controls);
      // the selection tool
      final ToolEntry tool = new SelectionToolEntry();
View Full Code Here

    controlGroup.addAll(entries);
    return controlGroup;
  }

  public static PaletteRoot createPalette() {
    PaletteRoot musicPalette = new PaletteRoot();
    musicPalette.addAll(createCategories(musicPalette));
    return musicPalette;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.gef.palette.PaletteRoot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.