blob: c9ccccd2ea60e8566042ce268a5112b47d3e7b54 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.click.eclipse.preferences;
import java.io.IOException;
import java.io.InputStream;
import org.apache.click.eclipse.ClickPlugin;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.graphics.RGB;
/**
* Initializes the preference store.
*
* @author Naoki Takezoe
*/
public class ClickPreferenceInitializer extends AbstractPreferenceInitializer {
public void initializeDefaultPreferences() {
IPreferenceStore store = ClickPlugin.getDefault().getPreferenceStore();
try {
store.setDefault(ClickPlugin.PREF_TEMPLATES, getResourceAsText("default_templates.xml"));
store.setDefault(ClickPlugin.PREF_COLOR_VAR, StringConverter.asString(new RGB(128,0,0)));
store.setDefault(ClickPlugin.PREF_COLOR_DIR, StringConverter.asString(new RGB(0,0,128)));
store.setDefault(ClickPlugin.PREF_COLOR_CMT, StringConverter.asString(new RGB(0,128,0)));
} catch(Exception ex){
ClickPlugin.log(ex);
}
}
private static String getResourceAsText(String resource) throws IOException {
InputStream in = null;
try {
in = ClickPreferenceInitializer.class.getResourceAsStream(resource);
byte[] buf = new byte[in.available()];
in.read(buf);
return new String(buf);
} finally {
if(in!=null){
in.close();
}
}
}
}