- added preference dialog
- added preference handling - added file monitor to automatically reload changed database
This commit is contained in:
@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* 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:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.preferences;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.resource.StringConverter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
import com.opcoach.e4.preferences.ScopedPreferenceStore;
|
||||
|
||||
public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
|
||||
|
||||
public final Color[] colors = new Color[WaveformColors.values().length];
|
||||
|
||||
public DefaultValuesInitializer() {
|
||||
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
||||
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
||||
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
|
||||
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
|
||||
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 128, 182);
|
||||
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
|
||||
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeDefaultPreferences() {
|
||||
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
|
||||
|
||||
store.setDefault(PreferenceConstants.DATABASE_RELOAD, true);
|
||||
for (WaveformColors c : WaveformColors.values()) {
|
||||
store.setDefault(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* 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:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.preferences;
|
||||
|
||||
public class PreferenceConstants {
|
||||
|
||||
public static final String PREFERENCES_SCOPE="com.minres.scviewer.e4.application";
|
||||
public static final String DATABASE_RELOAD="databaseReload";
|
||||
public static final String LINE_COLOR="LINE_COLOR";
|
||||
public static final String LINE_HIGHLITE_COLOR="LINE_HIGHLITE_COLOR";
|
||||
public static final String TRACK_BG_EVEN_COLOR="TRACK_BG_EVEN_COLOR";
|
||||
public static final String TRACK_BG_ODD_COLOR="TRACK_BG_ODD_COLOR";
|
||||
public static final String TRACK_BG_HIGHLITE_COLOR="TRACK_BG_HIGHLITE_COLOR";
|
||||
public static final String TX_BG_COLOR="TX_BG_COLOR";
|
||||
public static final String TX_BG_HIGHLITE_COLOR="TX_BG_HIGHLITE_COLOR";
|
||||
public static final String TX_BORDER_COLOR="TX_BORDER_COLOR";
|
||||
public static final String SIGNAL0_COLOR="SIGNAL0_COLOR";
|
||||
public static final String SIGNAL1_COLOR="SIGNAL1_COLOR";
|
||||
public static final String SIGNALZ_COLOR="SIGNALZ_COLOR";
|
||||
public static final String SIGNALX_COLOR="SIGNALX_COLOR";
|
||||
public static final String SIGNAL_TEXT_COLOR="SIGNAL_TEXT_COLOR";
|
||||
public static final String CURSOR_COLOR="CURSOR_COLOR";
|
||||
public static final String CURSOR_DRAG_COLOR="CURSOR_DRAG_COLOR";
|
||||
public static final String CURSOR_TEXT_COLOR="CURSOR_TEXT_COLOR";
|
||||
public static final String MARKER_COLOR="MARKER_COLOR";
|
||||
public static final String MARKER_TEXT_COLOR="MARKER_TEXT_COLOR";
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* 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:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.preferences;
|
||||
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
|
||||
/** A sample preference page to show how it works */
|
||||
public class SCViewerPreferencesPage extends FieldEditorPreferencePage {
|
||||
|
||||
public SCViewerPreferencesPage() {
|
||||
super(GRID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
|
||||
addField(new BooleanFieldEditor(PreferenceConstants.DATABASE_RELOAD, "Check for changed database",
|
||||
getFieldEditorParent()));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* 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:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.preferences;
|
||||
|
||||
import org.eclipse.jface.preference.ColorFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
/** A sample preference page to show how it works */
|
||||
public class WaveformPreferencesPage extends FieldEditorPreferencePage {
|
||||
|
||||
public WaveformPreferencesPage() {
|
||||
super(GRID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
|
||||
for (WaveformColors c : WaveformColors.values()) {
|
||||
addField(new ColorFieldEditor(c.name() + "_COLOR", "Color for " + c.name().toLowerCase(),
|
||||
getFieldEditorParent()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user