Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to Set Default Grid line style, line color, and "on top"
How to Set Default Grid line style, line color, and "on top" [message #997472] Mon, 07 January 2013 16:55 Go to next message
Nick Collier is currently offline Nick CollierFriend
Messages: 20
Registered: July 2009
Junior Member
I'm trying to set the default grid line color, line style and whether or not the grid should be on top. These properties don't seem to be constants in IPreferenceConstants, but I do see the relevant constants in WorkspaceViewerProperties. So, I'm trying this code in my DiagramPreferencesInitializer
 /**
   * @generated NOT
   */
  public void initializeDefaultPreferences() {
    IPreferenceStore store = getPreferenceStore();
    
 store.setDefault(org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties.GRIDLINECOLOR, SWT.COLOR_BLACK);
    store.setDefault(org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties.GRIDORDER, false);

    store.setDefault(IPreferenceConstants.PREF_SHOW_CONNECTION_HANDLES, true);
    store.setDefault(IPreferenceConstants.PREF_SHOW_POPUP_BARS, true);
    store.setDefault(IPreferenceConstants.PREF_ENABLE_ANIMATED_LAYOUT, true);
    store.setDefault(IPreferenceConstants.PREF_ENABLE_ANIMATED_ZOOM, true);
    store.setDefault(IPreferenceConstants.PREF_ENABLE_ANTIALIAS, true);
    store.setDefault(IPreferenceConstants.PREF_LINE_STYLE, Routing.MANUAL);
    store.setDefault(IPreferenceConstants.PREF_SHOW_RULERS, false);
    store.setDefault(IPreferenceConstants.PREF_RULER_UNITS, RulerProvider.UNIT_INCHES);
    store.setDefault(IPreferenceConstants.PREF_SHOW_GRID, true);
    store.setDefault(IPreferenceConstants.PREF_SNAP_TO_GRID, true);
    store.setDefault(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY, true);
    store.setDefault(IPreferenceConstants.PREF_GRID_SPACING, 0.125);
    store.setDefault(IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_MODEL, false);
    store.setDefault(IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_DIAGRAM, false);
  }


The IPreferenceConstants get picked up as defaults but the others don't. Any suggestions?

thanks,

Nick

[Updated on: Mon, 07 January 2013 16:59]

Report message to a moderator

Re: How to Set Default Grid line style, line color, and "on top" [message #1692800 is a reply to message #997472] Sat, 18 April 2015 22:48 Go to previous message
Nikos Margaritis is currently offline Nikos MargaritisFriend
Messages: 62
Registered: September 2014
Member

Hello there,

This is correct there are no IPreferenceConstants for those properties.

In order to achieve the expected results I had to add the following code under the xxxDiagramEditor.java (it does not work if you simply place it under initializeDefaultPreferences..)

@Override
	protected void addDefaultPreferences() {
		super.addDefaultPreferences();	
		getWorkspaceViewerPreferenceStore().setDefault(WorkspaceViewerProperties.GRIDORDER, 
				false);
		getWorkspaceViewerPreferenceStore().setDefault(WorkspaceViewerProperties.GRIDLINESTYLE, 
				SWT.LINE_DOT);
		getWorkspaceViewerPreferenceStore().setDefault(WorkspaceViewerProperties.GRIDLINECOLOR, 
				SWT.COLOR_BLACK);
	}


Hope it is useful.

Best, Nikos.

[Updated on: Sun, 19 April 2015 18:33]

Report message to a moderator

Previous Topic:org.eclipse.core.runtime.AssertionFailedException:
Next Topic:How can I create the connection line like in the figure
Goto Forum:
  


Current Time: Wed Jul 29 00:48:49 GMT 2015

Powered by FUDForum. Page generated in 0.09760 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software