Kaydet (Commit) e8fa7bbf authored tarafından Lei De Bin's avatar Lei De Bin

#119998# the VCLAuto code re-factor

Patch by: Liu Zhe(aliuzhe at gmail dot com) 
Review by: Lei Debin
üst 212ba19f
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.vclauto.assistant.feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<!--************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************ -->
<feature
id="org.vclauto.assistant.feature"
label="VclExplorer"
version="1.0.3.qualifier"
provider-name="Apache">
<description url="http://wiki.services.openoffice.org/wiki/QA/vclauto">
This plugin is tool to assist vclauto developers to write test
cases.
1. Inspect VCL control in OpenOffice.
2. Define VCL control in UIMap.
3. Insert testing code.
</description>
<copyright url="http://www.apache.org/licenses/LICENSE-2.0">
Apache License, Version 2.0
</copyright>
<license url="http://www.apache.org/licenses/LICENSE-2.0">
Apache License, Version 2.0
</license>
<plugin
id="org.vclauto.assistant"
download-size="120"
install-size="120"
version="0.0.0"
unpack="false"/>
</feature>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/vclauto.jar" sourcepath="/home/test/workspace/vclauto/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.vclauto.assistant</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Vclauto Assistant
Bundle-SymbolicName: org.vclauto.assistant; singleton:=true
Bundle-Version: 1.0.3.qualifier
Bundle-Activator: org.vclauto.assistant.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.editors;bundle-version="3.6.0",
org.eclipse.jface.text;bundle-version="3.6.0",
org.eclipse.core.resources;bundle-version="3.6.0",
org.eclipse.jdt.core;bundle-version="3.6.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .,
lib/vclauto.jar
Bundle-Vendor: Apache
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
contexts.xml,\
lib/vclauto.jar
<!--************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************ -->
<contexts>
<context id="viewer" title="Sample View">
<description>This is the context help for the sample view with a table viewer. It was generated by a PDE template.</description>
<topic href="/PLUGINS_ROOT/org.eclipse.platform.doc.isv/guide/ua_help_context.htm" label="Context-sensitive help">
<enablement>
<with variable="platform">
<test property="org.eclipse.core.runtime.isBundleInstalled" args="org.eclipse.platform.doc.isv"/>
</with>
</enablement>
</topic>
</context>
</contexts>
<?xml version="1.0" encoding="UTF-8"?>
<!--************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************ -->
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.views">
<category
name="Vclauto"
id="org.vclauto.assistant">
</category>
<view
name="Vcl Explorer"
icon="icons/sample.gif"
category="org.vclauto.assistant"
class="org.vclauto.assistant.views.VclExplorer"
id="org.vclauto.assistant.views.VclExplorer">
</view>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.jdt.ui.JavaPerspective">
<view
ratio="0.5"
relative="org.eclipse.ui.views.TaskList"
relationship="right"
id="org.vclauto.assistant.views.VclExplorer">
</view>
</perspectiveExtension>
</extension>
<extension
point="org.eclipse.help.contexts">
<contexts
file="contexts.xml">
</contexts>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
class="org.vclauto.assistant.preferences.PreferencePage"
id="org.vclauto.assistant.preferences.PreferencePage"
name="Vclauto Assistant">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.vclauto.assistant.preferences.PreferenceInitializer">
</initializer>
</extension>
</plugin>
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.vclauto.assistant;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.vclauto.assistant"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (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;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator 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) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.vclauto.assistant.preferences;
/**
* Constant definitions for plug-in preferences
*/
public class PreferenceConstants {
public static final String P_OPENOFFICE_HOME = "openoffice.home";
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.vclauto.assistant.preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.vclauto.assistant.Activator;
/**
* Class used to initialize default preference values.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(PreferenceConstants.P_OPENOFFICE_HOME, "");
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.vclauto.assistant.preferences;
import org.eclipse.jface.preference.*;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbench;
import org.vclauto.assistant.Activator;
/**
* This class represents a preference page that
* is contributed to the Preferences dialog. By
* subclassing <samp>FieldEditorPreferencePage</samp>, we
* can use the field support built into JFace that allows
* us to create a page that is small and knows how to
* save, restore and apply itself.
* <p>
* This page is used to modify preferences only. They
* are stored in the preference store that belongs to
* the main plug-in class. That way, preferences can
* be accessed directly via the preference store.
*/
public class PreferencePage
extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
public PreferencePage() {
super(GRID);
setPreferenceStore(Activator.getDefault().getPreferenceStore());
setDescription("Vclauto Assistant Setting");
}
/**
* Creates the field editors. Field editors are abstractions of
* the common GUI blocks needed to manipulate various types
* of preferences. Each field editor knows how to save and
* restore itself.
*/
public void createFieldEditors() {
addField(new DirectoryFieldEditor(PreferenceConstants.P_OPENOFFICE_HOME,
"&OpenOffice Home (the directory containing soffice.bin):", getFieldEditorParent()));
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
}
}
\ No newline at end of file
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.vclauto.assistant.views;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.vclauto.client.SmartId;
import org.vclauto.widgets.VclControl;
public class ControlInfo {
private static final HashMap<Long, String> vcltypes = new HashMap<Long, String>();
static {
Field[] fields = VclControl.class.getDeclaredFields();
for (Field field : fields) {
int modifiers = field.getModifiers();
if (modifiers == (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL) && field.getType() == Integer.TYPE) {
try {
int v = (Integer) field.get(null);
vcltypes.put((long)v, field.getName());
} catch (Exception e) {
//ignore
}
}
}
}
public SmartId id;
public long type;
public String tip;
public Image appearance;
public Rectangle rectangle;
public String name;
public ControlInfo(SmartId id, long type, String tip) {
super();
this.id = id;
this.type = type;
this.tip = tip;
}
public String getVclType() {
return vcltypes.get(type);
}
public void shot() {
if (id.getId() != 0 || id.getSid() != null) {
VclControl vclControl = new VclControl(id);
try {
if (!vclControl.exists())
return;
java.awt.Rectangle rect = vclControl.getScreenRectangle();
// Display display = Display.getDefault();
// GC gc = new GC(display);
rectangle = new Rectangle(rect.x, rect.y, rect.width, rect.height);
// appearance = new Image(display, rectangle);
// gc.copyArea(appearance, 0, 0);
// gc.dispose();
} catch (Throwable t) {
}
}
}
public void dispose() {
if (appearance != null)
appearance.dispose();
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.vclauto.assistant.views;
import java.util.ArrayList;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
public class VclExplorerContentProvider implements IStructuredContentProvider {
public VclExplorerContentProvider() {
}
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
ArrayList<ControlInfo> oldControlInfos = (ArrayList<ControlInfo>) oldInput;
if (oldControlInfos != null) {
for (ControlInfo info : oldControlInfos) {
info.dispose();
}
}
}
public void dispose() {
}
public Object[] getElements(Object parent) {
ArrayList<ControlInfo> controlInfos = (ArrayList<ControlInfo>) parent;
if (controlInfos != null)
return controlInfos.toArray();
return new Object[0];
}
}
\ No newline at end of file
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.vclauto.assistant.views;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
public class VclExplorerLabelProvider extends LabelProvider implements ITableLabelProvider {
public VclExplorerLabelProvider() {
}
public String getColumnText(Object obj, int index) {
ControlInfo info = (ControlInfo) obj;
switch (index) {
case 0:
return info.id.toString();
case 1:
return info.name;
case 2:
return Long.toString(info.type) + " " + info.getVclType();
case 3:
return info.tip;
}
return "";
}
public Image getColumnImage(Object obj, int index) {
return null;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment