Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » the problem of ZoomIn or ZoomOut button display in coolbar when open a editor.
the problem of ZoomIn or ZoomOut button display in coolbar when open a editor. [message #227949] Wed, 13 December 2006 03:40 Go to next message
Eclipse User
Originally posted by: jdenght.gmail.com

hi,everyone:
My eclipse version is 3.0.we are implementing a rcp.
the problem is :
when i open a editor,the zoomin or zoomout buttun can not display in
coolbar,but they can display in memu normally.

who can help me?
thanks very much!

the code in ActionBarContributor as follows:

public class DnrmDiagramActionBarContributor extends ActionBarContributor {

protected void buildActions() {

addRetargetAction(new ZoomInRetargetAction());
addRetargetAction(new ZoomOutRetargetAction());
}

public void contributeToCoolBar(ICoolBarManager coolBarManager) {
super.contributeToCoolBar(coolBarManager);
coolBarManager.add(createGraphToolbar(coolBarManager.getStyl e()));
}

/**
* @return ToolBarContributionItem SYSToolbar
*/
private ToolBarContributionItem createGraphToolbar(int style) {
IToolBarManager toolBarManager = new ToolBarManager(style);
toolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
toolBarManager.add(getAction(GEFActionConstants.ZOOM_IN));
toolBarManager.add(getAction(GEFActionConstants.ZOOM_OUT));
String[] zoomStrings = new String[]
{ZoomManager.FIT_ALL,ZoomManager.FIT_HEIGHT,ZoomManager.FIT_ WIDTH };
toolBarManager.add(new ZoomComboContributionItem(getPage(),zoomStrings));
return new
ToolBarContributionItem(toolBarManager,IMyWorkbenchActionCon stants.TOOLB_GROUP_GRAPH);
}

public void contributeToMenu(IMenuManager menubar) {
super.contributeToMenu(menubar);
MenuManager viewMenu = new MenuManager("VIEW");
viewMenu.add(getAction(GEFActionConstants.ZOOM_IN));
viewMenu.add(getAction(GEFActionConstants.ZOOM_OUT));

menubar.insertAfter(IWorkbenchActionConstants.M_FILE, viewMenu);
}

protected void declareGlobalActionKeys() {
addGlobalActionKey(ActionFactory.PRINT.getId());
}
}

the code in configureGraphicalViewer method of my editor as follows:

/**
* @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalV iewer()
*/
protected void configureGraphicalViewer(){
super.configureGraphicalViewer();
ScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart();
double[] zoomLevel = { .01, .1, .5, .75, 1.0, 1.5, 2.0, 2.5, 3, 4, 8,
15, 20, 40, 80, 100 };
root.getZoomManager().setZoomLevels(zoomLevel);

List zoomLevels = new ArrayList(3);
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
root.getZoomManager().setZoomLevelContributions(zoomLevels);

IAction zoomIn = new ZoomInAction(root.getZoomManager());
IAction zoomOut = new ZoomOutAction(root.getZoomManager());
getActionRegistry().registerAction(zoomIn);
getActionRegistry().registerAction(zoomOut);
getSite().getKeyBindingService().registerAction(zoomIn);
getSite().getKeyBindingService().registerAction(zoomOut);


getGraphicalViewer().setRootEditPart(root);
getGraphicalViewer().setEditPartFactory(new DnrmEditPartFactory());


ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer)
getGraphicalViewer();

ContextMenuProvider provider = new
DnrmContextMenuProvider(viewer,getActionRegistry());//
Re: the problem of ZoomIn or ZoomOut button display in coolbar when open a editor. [message #228028 is a reply to message #227949] Wed, 13 December 2006 21:22 Go to previous message
Eclipse User
Originally posted by: jdenght.gmail.com

i have implemented the problem.i do it like this:
public void contributeToToolBar(IToolBarManager toolBarManager) {
super.contributeToToolBar(toolBarManager);
toolBarManager.add(new Separator());
toolBarManager.add(getAction(GEFActionConstants.ALIGN_TOP));
toolBarManager.add(getAction(GEFActionConstants.ALIGN_BOTTOM ));
toolBarManager.add(getAction(GEFActionConstants.ALIGN_MIDDLE ));
toolBarManager.add(getAction(GEFActionConstants.ALIGN_LEFT)) ;
toolBarManager.add(getAction(GEFActionConstants.ALIGN_RIGHT) );
toolBarManager.add(getAction(GEFActionConstants.ALIGN_CENTER ));
toolBarManager.add(new Separator());
toolBarManager.add(getAction(GEFActionConstants.ZOOM_IN));
toolBarManager.add(getAction(GEFActionConstants.ZOOM_OUT));
String[] zoomStrings = new String[]
{ZoomManager.FIT_ALL,ZoomManager.FIT_HEIGHT,ZoomManager.FIT_ WIDTH };
toolBarManager.add(new ZoomComboContributionItem(getPage(),zoomStrings));
}

"jdenght" <jdenght@gmail.com> ะด
Previous Topic:DnD enablement
Next Topic:how to pull in GEF source for debugging?
Goto Forum:
  


Current Time: Wed Apr 16 03:26:17 EDT 2014

Powered by FUDForum. Page generated in 0.02277 seconds