2012-06-17 20:34:50 +02:00
|
|
|
/*******************************************************************************
|
2015-10-22 00:25:12 +02:00
|
|
|
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
2012-06-17 20:34:50 +02:00
|
|
|
* 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:
|
2015-01-21 21:58:35 +01:00
|
|
|
* MINRES Technologies GmbH - initial API and implementation
|
2012-06-17 20:34:50 +02:00
|
|
|
*******************************************************************************/
|
2015-01-03 16:34:32 +01:00
|
|
|
package com.minres.scviewer.ui;
|
2012-06-17 19:53:05 +02:00
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.MissingResourceException;
|
|
|
|
import java.util.ResourceBundle;
|
|
|
|
|
|
|
|
import org.eclipse.jface.resource.ImageDescriptor;
|
2015-01-03 16:34:32 +01:00
|
|
|
import org.eclipse.swt.SWT;
|
2012-06-17 19:53:05 +02:00
|
|
|
import org.eclipse.swt.graphics.Color;
|
|
|
|
import org.eclipse.swt.graphics.Image;
|
|
|
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
2015-01-01 23:17:32 +01:00
|
|
|
import org.eclipse.wb.swt.SWTResourceManager;
|
2012-06-17 19:53:05 +02:00
|
|
|
import org.osgi.framework.BundleContext;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The activator class controls the plug-in life cycle
|
|
|
|
*/
|
|
|
|
public class TxEditorPlugin extends AbstractUIPlugin {
|
|
|
|
|
|
|
|
public static final int lineColor=0;
|
|
|
|
public static final int txBgColor=1;
|
|
|
|
public static final int highliteLineColor=2;
|
|
|
|
public static final int txHighliteBgColor=3;
|
|
|
|
public static final int trackBgLightColor=4;
|
|
|
|
public static final int trackBgDarkColor=5;
|
|
|
|
public static final int headerBgColor=6;
|
|
|
|
public static final int headerFgColor=7;
|
|
|
|
|
|
|
|
// The plug-in ID
|
2015-01-03 16:34:32 +01:00
|
|
|
public static final String PLUGIN_ID = "com.minres.scviewer.ui"; //$NON-NLS-1$
|
2012-06-17 19:53:05 +02:00
|
|
|
|
|
|
|
// The shared instance
|
|
|
|
private static TxEditorPlugin plugin;
|
|
|
|
|
|
|
|
private ResourceBundle resourceBundle;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The constructor
|
|
|
|
*/
|
2015-01-03 16:34:32 +01:00
|
|
|
// public TxEditorPlugin() {
|
|
|
|
// openedTxEditorPart=null;
|
|
|
|
// }
|
2012-06-17 19:53:05 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* (non-Javadoc)
|
|
|
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
|
|
|
*/
|
|
|
|
public void start(BundleContext context) throws Exception {
|
|
|
|
super.start(context);
|
|
|
|
plugin = this;
|
|
|
|
try {
|
|
|
|
resourceBundle = ResourceBundle.getBundle(plugin.getClass().getName());
|
|
|
|
} catch (MissingResourceException x) {
|
|
|
|
resourceBundle = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (non-Javadoc)
|
|
|
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
|
|
|
*/
|
|
|
|
public void stop(BundleContext context) throws Exception {
|
|
|
|
plugin = null;
|
2015-01-01 23:17:32 +01:00
|
|
|
SWTResourceManager.dispose();
|
2012-06-17 19:53:05 +02:00
|
|
|
super.stop(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the shared instance
|
|
|
|
*
|
|
|
|
* @return the shared instance
|
|
|
|
*/
|
|
|
|
public static TxEditorPlugin getDefault() {
|
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an image descriptor for the image file at the given
|
|
|
|
* plug-in relative path
|
|
|
|
*
|
|
|
|
* @param path the path
|
|
|
|
* @return the image descriptor
|
|
|
|
*/
|
|
|
|
public static ImageDescriptor getImageDescriptor(String path) {
|
|
|
|
String fullpath = File.separator+"res"+File.separator+"images"+File.separator+path;
|
|
|
|
return imageDescriptorFromPlugin(PLUGIN_ID, fullpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Image createImage(String name) {
|
|
|
|
ImageDescriptor id=getImageDescriptor(name+".png");
|
|
|
|
return id.createImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Color getColor(int idx){
|
|
|
|
switch (idx) {
|
|
|
|
case lineColor:
|
2015-01-03 16:34:32 +01:00
|
|
|
return SWTResourceManager.getColor(SWT.COLOR_RED);
|
2012-06-17 19:53:05 +02:00
|
|
|
case txBgColor:
|
2015-01-03 16:34:32 +01:00
|
|
|
return SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
2012-06-17 19:53:05 +02:00
|
|
|
case highliteLineColor:
|
2015-01-03 16:34:32 +01:00
|
|
|
return SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
2012-06-17 19:53:05 +02:00
|
|
|
case txHighliteBgColor:
|
2015-01-03 16:34:32 +01:00
|
|
|
return SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
2012-06-17 19:53:05 +02:00
|
|
|
case trackBgLightColor:
|
2015-01-01 23:17:32 +01:00
|
|
|
return SWTResourceManager.getColor(220, 220, 220);
|
2012-06-17 19:53:05 +02:00
|
|
|
case trackBgDarkColor:
|
2015-01-09 09:16:40 +01:00
|
|
|
// return SWTResourceManager.getColor(200, 200, 200);
|
|
|
|
return SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
2012-06-17 19:53:05 +02:00
|
|
|
case headerBgColor:
|
2015-01-01 23:17:32 +01:00
|
|
|
return SWTResourceManager.getColor(255, 255, 255);
|
2012-06-17 19:53:05 +02:00
|
|
|
case headerFgColor:
|
2015-01-01 23:17:32 +01:00
|
|
|
return SWTResourceManager.getColor(55, 55, 55);
|
2012-06-17 19:53:05 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-01-03 16:34:32 +01:00
|
|
|
return SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
2012-06-17 19:53:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ResourceBundle getResourceBundle() {
|
|
|
|
return resourceBundle;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|