Révision 1693

tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/preferences/ChartsEnginePreferencePage.java (revision 1693)
74 74
		this.addField(this.chartsEngineComboField);
75 75

  
76 76
		
77
		// export formats
77
		// current engine supported export formats
78 78
		ArrayList<String> supportedExportFormats = new ArrayList<String>();
79
		supportedExportFormats.addAll(ChartsEngine.getCurrent().getSupportedOutputFileFormats());
79
		supportedExportFormats.addAll(((ChartsEngine) Toolbox.getEngineManager(EngineType.CHARTS).getCurrentEngine()).getSupportedOutputFileFormats());
80 80
		
81 81
		// Sort the set
82 82
		TreeSet<String> formatsSet = new TreeSet <String>(supportedExportFormats);
......
97 97
		// Monochrome color
98 98
		this.addField(new ColorFieldEditor(ChartsEnginePreferences.MONOCHROME_COLOR, SWTComponentsProviderMessages.monochromeRenderingColor, this.getFieldEditorParent()));
99 99
		
100
		FontFieldEditor font = new FontFieldEditor(ChartsEnginePreferences.FONT, "Font", "Specificities / Spécificités / Специфичность", this.getFieldEditorParent());
100
		FontFieldEditor font = new FontFieldEditor(ChartsEnginePreferences.FONT, "Font", "Specificities / Spécificités / Специфичность", this.getFieldEditorParent()); //$NON-NLS-1$ //$NON-NLS-2$
101 101
		this.addField(font);
102 102
		// FIXME: preview area tests
103 103
		//font.fillIntoGrid(this.getFieldEditorParent(), 4);
......
112 112
	public void propertyChange(PropertyChangeEvent event) {
113 113
		super.propertyChange(event);
114 114

  
115
		// Store the property changed state for not recreating a new ChartsEngin if the property hasn't been changed  
116
		this.hasChanged = true;
115
		// Store the property changed state for not recreating a new ChartsEngine if the property hasn't been changed
116
		// NOTE: SJ: warning, event.getProperty() seems bugged and does not return the correct property name but the string "field_value_editor"
117
		if(event.getSource() == this.chartsEngineComboField && !event.getNewValue().equals(event.getOldValue()))	{
118
			this.hasChanged = true;
119
		}
117 120
	}
118 121
	
119 122

  
......
127 130
	@Override
128 131
	public boolean performOk() {
129 132
			
130
			super.performOk();
133
		super.performOk();
131 134

  
132
			// Do nothing if the property has not been changed
133
			if(this.hasChanged) {
134
				
135
				Log.info(SWTComponentsProviderMessages.recreatingChartsEngineAndSWTChartComponentsProvider);
135
		
136
		// Set the new monochrome color for all charts engine theme
137
		for(int i = 0; i < ChartsEngine.getChartsEngines().size(); i++) {
138
			ChartsEngine.getChartsEngines().get(i).getTheme().setMonochromeColor(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.MONOCHROME_COLOR));
139
		}
140
		
136 141

  
137
				Toolbox.getEngineManager(EngineType.CHARTS).setCurrentEngine(this.getPreferenceStore().getString(ChartsEnginePreferences.CURRENT_NAME));
138
				
139
				// Sets the new current charts SWT component provider according to the new current charts engine
140
				SWTChartsComponentsProvider.setCurrrentComponentsProvider((ChartsEngine) Toolbox.getEngineManager(EngineType.CHARTS).getCurrentEngine());
141
				
142
				// Set the first charts engine supported export file format as default charts export file format
143
				ChartsEnginePreferences.getInstance().put(ChartsEnginePreferences.DEFAULT_EXPORT_FORMAT, ChartsEngine.getCurrent().getSupportedOutputFileFormats().get(0));
144
				
145
				
146
				// Set the new monochrome color for all charts engine theme
147
				for(int i = 0; i < ChartsEngine.getChartsEngines().size(); i++) {
148
					ChartsEngine.getChartsEngines().get(i).getTheme().setMonochromeColor(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.MONOCHROME_COLOR));
149
				}
150
				
151
				// FIXME: doesn't work, works only when we quit the page and go back to it
152
				// Refreshes the page to recreate the default export format combo box 
153
//				PlatformUI.getWorkbench().getPreferenceManager().
154
//				find("org.txm.rcp.preferences.TXMMainPreferencePage/org.txm.rcp.preferences.AdvancePreferencePage/ChartsEnginePreferencePage").createPage(); //$NON-NLS-1$
155
				
156
				//FIXME: old code
157
				// Refresh the User\Export preference page to update "Default charts export file format" combo box
158
//				PlatformUI.getWorkbench().getPreferenceManager().
159
//					find("org.txm.rcp.preferences.TXMMainPreferencePage/" + UserPreferencePage.ID + "/" + ExportPreferencePage.ID).createPage(); //$NON-NLS-1$ //$NON-NLS-2$
160
			}
142
		// Only if the current engine has changed
143
		if(this.hasChanged) {
144
			
145
			Log.info(SWTComponentsProviderMessages.recreatingChartsEngineAndSWTChartComponentsProvider);
161 146

  
162
//			// FIXME: useless ?
163
//			Explorer.refresh();
147
			Toolbox.getEngineManager(EngineType.CHARTS).setCurrentEngine(this.getPreferenceStore().getString(ChartsEnginePreferences.CURRENT_NAME));
164 148
			
149
			// Sets the new current charts SWT component provider according to the new current charts engine
150
			SWTChartsComponentsProvider.setCurrrentComponentsProvider((ChartsEngine) Toolbox.getEngineManager(EngineType.CHARTS).getCurrentEngine());
151
			
152
			// Reset the default export format to the new charts engine first supported export file format
153
			ChartsEnginePreferences.getInstance().put(ChartsEnginePreferences.DEFAULT_EXPORT_FORMAT, ChartsEngine.getCurrent().getSupportedOutputFileFormats().get(0));
154
			
155
			
156
		}
157

  
165 158
		return true;
166 159
	}
167 160
}

Formats disponibles : Unified diff