/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.wgadesigner.preferences;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import de.innovationgate.eclipse.wgadesigner.WGADesignerPlugin;
import de.innovationgate.eclipse.wgadesigner.models.DesignTemplate;
public class PreferenceInitializer extends AbstractPreferenceInitializer {
public void initializeDefaultPreferences() {
normalizeDesignTemplates();
createDefaultDesignTemplates();
IPreferenceStore store = WGADesignerPlugin.getDefault().getPreferenceStore();
store.setDefault(PreferenceConstants.JAVA_DEBUG, false);
store.setDefault(PreferenceConstants.TMLSCRIPT_DEBUG, false);
store.setDefault(PreferenceConstants.JAVA_MIN_HEAP_SIZE, 128);
store.setDefault(PreferenceConstants.JAVA_MAX_HEAP_SIZE, 256);
store.setDefault(PreferenceConstants.JAVA_MIN_PERMGEN_SIZE, 64);
store.setDefault(PreferenceConstants.JAVA_MAX_PERMGEN_SIZE, 128);
store.setDefault(PreferenceConstants.JMX_PORT, 1557);
store.setDefault(PreferenceConstants.TOMCAT_SERVER_PORT, 8005);
store.setDefault(PreferenceConstants.TOMCAT_HTTP_PORT, 8080);
store.setDefault(PreferenceConstants.TOMCAT_REDIRECT_PORT, 8443);
}
private void normalizeDesignTemplates() {
/*
IPreferenceStore store = WGADesignerPlugin.getDefault().getPreferenceStore();
try {
DesignTemplateStore templateStore = DesignTemplateStore.fromXML(store.getString(PreferenceConstants.DESIGN_TEMPLATES_V1));
// convert old style templates
Set<DesignTemplate> oldtemplates = templateStore.getTemplates();
List<DesignTemplate> newtemplates = WGADesignerPlugin.getDefault().getDesginTemplateStore().getBeans();
newtemplates.addAll(oldtemplates);
WGADesignerPlugin.getDefault().getDesginTemplateStore().flush();
store.setValue(PreferenceConstants.DESIGN_TEMPLATES_V1, null);
} catch (Throwable e) {
// none old style templates - nothing to do
}
*/
}
public static List<DesignTemplate> getDefaultTemplates(){
List<DesignTemplate> templates = new ArrayList<DesignTemplate>();
templates.add(new DesignTemplate("empty", "resources/templates/empty.zip"));
templates.add(new DesignTemplate("website-sample", "resources/templates/cms-sample.zip"));
templates.add(new DesignTemplate("application-sample", "resources/templates/app-sample.zip"));
return templates;
}
private void createDefaultDesignTemplates() {
WGADesignerPlugin.getDefault().getDesginTemplateStore().setDefault(getDefaultTemplates());
}
}