mirror of https://github.com/mchr3k/org.intrace
Initial eclipse version which actually works
This commit is contained in:
parent
9385ec9b6c
commit
e19187da6b
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>intrace.ecl.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>
|
||||
|
|
@ -0,0 +1 @@
|
|||
bin.includes = feature.xml
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="intrace.ecl.feature"
|
||||
label="InTrace Eclipse"
|
||||
version="0.0.0.1">
|
||||
|
||||
<description url="https://github.com/mchr3k/org.intrace/wiki">
|
||||
Enable launching Java Applications with the InTrace agent.
|
||||
</description>
|
||||
|
||||
<copyright>
|
||||
Copyright reserved by mchr3k@gmail.com
|
||||
</copyright>
|
||||
|
||||
<license>
|
||||
Published under the EPL.
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="intrace.ecl"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
|
|
@ -3,5 +3,7 @@
|
|||
<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="lib" path="lib/miglayout-3.7.3.1-swt.jar"/>
|
||||
<classpathentry kind="lib" path="lib/intrace-ui-helper.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>intrace.eclipse</name>
|
||||
<name>intrace.ecl.plugin</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: InTrace Eclipse
|
||||
Bundle-SymbolicName: intrace.ecl;singleton:=true
|
||||
Bundle-Version: 0.0.0.1
|
||||
Bundle-Activator: intrace.ecl.Activator
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.debug.core,
|
||||
org.eclipse.debug.ui,
|
||||
org.eclipse.jdt.debug.ui;bundle-version="3.5.2",
|
||||
org.eclipse.jdt.launching;bundle-version="3.5.200",
|
||||
org.eclipse.ui.ide;bundle-version="3.6.2"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ClassPath: lib/miglayout-3.7.3.1-swt.jar,
|
||||
.,
|
||||
lib/intrace-ui-helper.jar
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
lib/intrace-agent.jar,\
|
||||
lib/miglayout-3.7.3.1-swt.jar,\
|
||||
lib/intrace-ui-helper.jar
|
||||
|
Before Width: | Height: | Size: 881 B After Width: | Height: | Size: 881 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -12,8 +12,8 @@
|
|||
<extension
|
||||
point="org.eclipse.debug.core.launchDelegates">
|
||||
<launchDelegate
|
||||
delegate="intrace.eclipse.InTraceLaunchConfigurationDelegate"
|
||||
id="intrace.eclipse.intraceLaunchDelegate"
|
||||
delegate="intrace.ecl.ui.launching.ConfigurationDelegate"
|
||||
id="intrace.ecl.intraceLaunchDelegate"
|
||||
modes="intrace"
|
||||
name="Java Application"
|
||||
type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
point="org.eclipse.debug.ui.launchGroups">
|
||||
<launchGroup
|
||||
bannerImage="icons/runcoverage.gif"
|
||||
id="intrace.eclipse.launchGroup.InTrace"
|
||||
id="intrace.ecl.inTraceLaunchGroup"
|
||||
image="icons/runcoverage.gif"
|
||||
label="InTrace"
|
||||
mode="intrace">
|
||||
|
|
@ -32,11 +32,11 @@
|
|||
<extension
|
||||
point="org.eclipse.ui.actionSets">
|
||||
<actionSet
|
||||
id="intrace.eclipse.inTraceActionSet"
|
||||
id="intrace.ecl.inTraceActionSet"
|
||||
label="InTrace"
|
||||
visible="false">
|
||||
<action
|
||||
class="intrace.eclipse.actions.InTraceToolbarAction"
|
||||
class="intrace.ecl.ui.launching.ToolbarAction"
|
||||
disabledIcon="icons/runcoverage.gif"
|
||||
hoverIcon="icons/runcoverage.gif"
|
||||
icon="icons/runcoverage.gif"
|
||||
|
|
@ -52,16 +52,16 @@
|
|||
<perspectiveExtension
|
||||
targetID="org.eclipse.jdt.ui.JavaPerspective">
|
||||
<actionSet
|
||||
id="intrace.eclipse.inTraceActionSet">
|
||||
id="intrace.ecl.inTraceActionSet">
|
||||
</actionSet>
|
||||
</perspectiveExtension>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchShortcuts">
|
||||
<shortcut
|
||||
class="intrace.eclipse.ui.launching.InTraceLaunchShortcut"
|
||||
class="intrace.ecl.ui.launching.Shortcut"
|
||||
icon="icons/runcoverage.gif"
|
||||
id="intrace.eclipse.ui.localJavaShortcut"
|
||||
id="intrace.ecl.inTraceLocalJavaShortcut"
|
||||
label="Java Application"
|
||||
modes="intrace">
|
||||
<contextualLaunch>
|
||||
|
|
@ -82,5 +82,23 @@
|
|||
</contextualLaunch>
|
||||
</shortcut>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
|
||||
<launchConfigurationTabGroup
|
||||
class="intrace.ecl.ui.launching.TabGroup"
|
||||
id="intrace.ecl.JavaAppTabGroup"
|
||||
type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
</launchConfigurationTabGroup>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.editors">
|
||||
<editor
|
||||
class="intrace.ecl.plugin.ui.output.InTraceEditor"
|
||||
default="false"
|
||||
icon="icons/runcoverage.gif"
|
||||
id="intrace.ecl.plugin.ui.output.inTraceEditor"
|
||||
name="InTrace Output">
|
||||
</editor>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
package intrace.eclipse;
|
||||
package intrace.ecl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
|
|
@ -9,11 +14,14 @@ import org.osgi.framework.BundleContext;
|
|||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "intrace.eclipse"; //$NON-NLS-1$
|
||||
public static final String PLUGIN_ID = "intrace.ecl"; //$NON-NLS-1$
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
// Agent arg
|
||||
public String agentArg = "";
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
|
|
@ -26,7 +34,24 @@ public class Activator extends AbstractUIPlugin {
|
|||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
plugin = this;
|
||||
getJar();
|
||||
}
|
||||
|
||||
private void getJar()
|
||||
{
|
||||
Bundle b = getBundle();
|
||||
try
|
||||
{
|
||||
File bundleDir = FileLocator.getBundleFile(b);
|
||||
File jarFile = new File(bundleDir, "lib/intrace-agent.jar");
|
||||
String absPath = jarFile.getAbsolutePath();
|
||||
agentArg = " -javaagent:" + absPath;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package intrace.ecl;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
public class Util
|
||||
{
|
||||
public static IStatus errorStatus(String message, Throwable t) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, message, t);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package intrace.ecl.plugin.ui.output;
|
||||
|
||||
public class ClientStrings
|
||||
{
|
||||
public static final String ENABLE_INSTR = "Add Instrumentation";
|
||||
public static final String ENABLING_INSTR = "Adding Instrumenting...";
|
||||
public static final String DISABLING_INSTR = "Removing Instrumentation...";
|
||||
public static final String DISABLE_INSTR = "Remove Instrumentation";
|
||||
public static final String SET_CLASSREGEX = "Select Classes ...";
|
||||
public static final String ENABLE_ALLOWJARS = "Instru JARs";
|
||||
public static final String ENABLE_SAVECLASSES = "Save Instrumented Classes";
|
||||
public static final String ENABLE_VERBOSEMODE = "Verbose Mode";
|
||||
public static final String LIST_MODIFIED_CLASSES = "List Instrumented Classes";
|
||||
|
||||
public static final String ENABLE_EE_TRACE = "Entry/Exit Trace";
|
||||
public static final String ENABLE_BRANCH_TRACE = "Branch Trace";
|
||||
public static final String ENABLE_ARGS_TRACE = "Args Trace";
|
||||
|
||||
public static final String BEGIN_CAPTURE_CALLERS = "New Callers Capture...";
|
||||
public static final String END_CAPTURE_CALLERS = "End Callers Capture";
|
||||
|
||||
public static final String ENABLE_STDOUT_OUTPUT = "StdOut";
|
||||
public static final String ENABLE_FILE_OUTPUT = "File";
|
||||
public static final String ENABLE_NETWORK_OUTPUT = "Collect Trace";
|
||||
public static final String ENABLE_FILTER = "Enable Filter";
|
||||
|
||||
public static final String CONNECT = "Connect";
|
||||
public static final String CONNECTING = "Connect...";
|
||||
public static final String DISCONNECT = "Disconnect";
|
||||
public static final String CONN_ADDRESS = "Address:";
|
||||
public static final String CONN_PORT = "Port:";
|
||||
public static final String CONN_STATUS = "Status: ";
|
||||
|
||||
public static final String DUMP_SETTINGS = "Dump Settings";
|
||||
|
||||
public static final String CAPTURE_END = "End Capture";
|
||||
public static final String CAPTURE_CLOSE = "Close";
|
||||
|
||||
public static final String CLEAR_TEXT = "Clear";
|
||||
public static final String AUTO_SCROLL = "Auto Scroll";
|
||||
public static final String FILTER_TEXT = "Filter...";
|
||||
public static final String CANCEL_TEXT = "Cancel";
|
||||
public static final String SAVE_TEXT = "Save Output...";
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package intrace.ecl.plugin.ui.output;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IPersistableElement;
|
||||
|
||||
public class EditorInput implements IEditorInput
|
||||
{
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Object getAdapter(Class adapter)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageDescriptor getImageDescriptor()
|
||||
{
|
||||
return ImageDescriptor.getMissingImageDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "InTraceInput";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPersistableElement getPersistable()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTipText()
|
||||
{
|
||||
return "InTraceInput";
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,141 @@
|
|||
package intrace.ecl.ui.launching;
|
||||
|
||||
import intrace.ecl.Activator;
|
||||
import intrace.ecl.Util;
|
||||
import intrace.ecl.plugin.ui.output.EditorInput;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExecutableExtension;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.core.ILaunchesListener2;
|
||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
||||
import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
|
||||
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
public class ConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate implements IExecutableExtension
|
||||
{
|
||||
protected String launchtype;
|
||||
|
||||
protected ILaunchConfigurationDelegate launchdelegate;
|
||||
|
||||
// IExecutableExtension interface:
|
||||
|
||||
public void setInitializationData(IConfigurationElement config,
|
||||
String propertyName, Object data) throws CoreException
|
||||
{
|
||||
launchtype = config.getAttribute("type"); //$NON-NLS-1$
|
||||
launchdelegate = getLaunchDelegate(launchtype);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private ILaunchConfigurationDelegate getLaunchDelegate(String launchtype)
|
||||
throws CoreException
|
||||
{
|
||||
ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager()
|
||||
.getLaunchConfigurationType(launchtype);
|
||||
if (type == null)
|
||||
{
|
||||
throw new CoreException(Util.errorStatus("Unknown launch type", new Throwable()));
|
||||
}
|
||||
return type.getDelegate(ILaunchManager.RUN_MODE);
|
||||
}
|
||||
|
||||
// ILaunchConfigurationDelegate interface:
|
||||
|
||||
@Override
|
||||
public void launch(ILaunchConfiguration configuration, String mode,
|
||||
ILaunch launch, IProgressMonitor monitor) throws CoreException
|
||||
{
|
||||
// Add VM arguments
|
||||
ILaunchConfigurationWorkingCopy wc = configuration.getWorkingCopy();
|
||||
String vmArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "");
|
||||
vmArgs += Activator.getDefault().agentArg;
|
||||
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs);
|
||||
|
||||
// Add listener for termination
|
||||
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
||||
launchManager.addLaunchListener(new TerminationListener(launch));
|
||||
|
||||
// Launch editor input
|
||||
final IWorkbench workbench = PlatformUI.getWorkbench();
|
||||
Display display = workbench.getDisplay();
|
||||
display.asyncExec(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
|
||||
IWorkbenchPage page = window.getActivePage();
|
||||
IDE.openEditor(page, new EditorInput(), "intrace.ecl.plugin.ui.output.inTraceEditor");
|
||||
}
|
||||
catch (PartInitException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Start launch
|
||||
launchdelegate.launch(wc, ILaunchManager.RUN_MODE, launch,
|
||||
new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
|
||||
public static class TerminationListener implements ILaunchesListener2
|
||||
{
|
||||
private final ILaunch target;
|
||||
|
||||
public TerminationListener(ILaunch target)
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchesRemoved(ILaunch[] launches)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchesAdded(ILaunch[] launches)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchesChanged(ILaunch[] launches)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchesTerminated(ILaunch[] launches)
|
||||
{
|
||||
for (ILaunch launch : launches)
|
||||
{
|
||||
if (launch == target)
|
||||
{
|
||||
System.out.println("Removed");
|
||||
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
||||
launchManager.removeLaunchListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package intrace.ecl.ui.launching;
|
||||
|
||||
import intrace.ecl.Activator;
|
||||
import intrace.ecl.Util;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.debug.ui.ILaunchShortcut;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
|
||||
public class Shortcut implements ILaunchShortcut
|
||||
{
|
||||
private final String delegateId = "org.eclipse.jdt.debug.ui.localJavaShortcut";
|
||||
private ILaunchShortcut delegate;
|
||||
|
||||
private ILaunchShortcut getDelegate()
|
||||
{
|
||||
if (delegate == null)
|
||||
{
|
||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
|
||||
.getExtensionPoint(IDebugUIConstants.PLUGIN_ID,
|
||||
IDebugUIConstants.EXTENSION_POINT_LAUNCH_SHORTCUTS);
|
||||
IConfigurationElement[] configs = extensionPoint
|
||||
.getConfigurationElements();
|
||||
for (IConfigurationElement config : configs)
|
||||
{
|
||||
String configID = config.getAttribute("id");
|
||||
if (delegateId.equals(configID)) { //$NON-NLS-1$
|
||||
try
|
||||
{
|
||||
delegate = (ILaunchShortcut) config
|
||||
.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
Activator.getDefault().getLog().log(Util.errorStatus("Error", e));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (delegate == null)
|
||||
{
|
||||
String msg = "ILaunchShortcut declaration not found: " + delegateId; //$NON-NLS-1$
|
||||
Activator.getDefault().getLog().log(Util.errorStatus(msg, null));
|
||||
}
|
||||
}
|
||||
return delegate;
|
||||
}
|
||||
|
||||
// ILaunchShortcut interface:
|
||||
|
||||
public void launch(ISelection selection, String mode)
|
||||
{
|
||||
ILaunchShortcut delegate = getDelegate();
|
||||
if (delegate != null)
|
||||
{
|
||||
delegate.launch(selection, "intrace");
|
||||
}
|
||||
}
|
||||
|
||||
public void launch(IEditorPart editor, String mode)
|
||||
{
|
||||
ILaunchShortcut delegate = getDelegate();
|
||||
if (delegate != null)
|
||||
{
|
||||
delegate.launch(editor, "intrace");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package intrace.ecl.ui.launching;
|
||||
|
||||
import intrace.ecl.Util;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExecutableExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
|
||||
|
||||
public class TabGroup extends AbstractLaunchConfigurationTabGroup implements IExecutableExtension
|
||||
{
|
||||
private static final String DELEGATE_LAUNCHMODE = ILaunchManager.RUN_MODE;
|
||||
private static final String EXPOINT_TABGROUP = "org.eclipse.debug.ui.launchConfigurationTabGroups"; //$NON-NLS-1$
|
||||
private static final String CONFIGATTR_TYPE = "type"; //$NON-NLS-1$
|
||||
|
||||
private ILaunchConfigurationTabGroup tabGroupDelegate;
|
||||
|
||||
public void setInitializationData(IConfigurationElement config,
|
||||
String propertyName, Object data) throws CoreException
|
||||
{
|
||||
tabGroupDelegate = createDelegate(config.getAttribute(CONFIGATTR_TYPE));
|
||||
}
|
||||
|
||||
protected ILaunchConfigurationTabGroup createDelegate(String type)
|
||||
throws CoreException
|
||||
{
|
||||
IExtensionPoint extensionpoint = Platform.getExtensionRegistry()
|
||||
.getExtensionPoint(EXPOINT_TABGROUP);
|
||||
IConfigurationElement[] tabGroupConfigs = extensionpoint
|
||||
.getConfigurationElements();
|
||||
IConfigurationElement element = null;
|
||||
findloop: for (IConfigurationElement tabGroupConfig : tabGroupConfigs)
|
||||
{
|
||||
if (type.equals(tabGroupConfig.getAttribute(CONFIGATTR_TYPE)))
|
||||
{
|
||||
IConfigurationElement[] modeConfigs = tabGroupConfig
|
||||
.getChildren("launchMode"); //$NON-NLS-1$
|
||||
for (IConfigurationElement modeConfig : modeConfigs)
|
||||
{
|
||||
if (DELEGATE_LAUNCHMODE.equals(modeConfig.getAttribute("mode"))) { //$NON-NLS-1$
|
||||
element = tabGroupConfig;
|
||||
break findloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
String msg = "No tab group registered to run " + type; //$NON-NLS-1$;
|
||||
throw new CoreException(Util.errorStatus(msg, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ILaunchConfigurationTabGroup) element
|
||||
.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode)
|
||||
{
|
||||
tabGroupDelegate.createTabs(dialog, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationTab[] getTabs()
|
||||
{
|
||||
return tabGroupDelegate.getTabs();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package intrace.ecl.ui.launching;
|
||||
|
||||
import org.eclipse.debug.ui.actions.AbstractLaunchToolbarAction;
|
||||
|
||||
public class ToolbarAction extends AbstractLaunchToolbarAction
|
||||
{
|
||||
|
||||
public ToolbarAction()
|
||||
{
|
||||
super("intrace.ecl.inTraceLaunchGroup");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>intrace.ecl.site</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.UpdateSiteBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.UpdateSiteNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site>
|
||||
<feature url="features/intrace.ecl.feature_0.0.0.1.jar" id="intrace.ecl.feature" version="0.0.0.1">
|
||||
<category name="intrace.ecl.category"/>
|
||||
</feature>
|
||||
<category-def name="intrace.ecl.category" label="InTrace"/>
|
||||
</site>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: InTrace Eclipse
|
||||
Bundle-SymbolicName: intrace.eclipse;singleton:=true
|
||||
Bundle-Version: 0.0.0.1
|
||||
Bundle-Activator: intrace.eclipse.Activator
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.debug.core,
|
||||
org.eclipse.debug.ui
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
package intrace.eclipse;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchDelegate;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
||||
|
||||
public class InTraceLaunchConfigurationDelegate implements
|
||||
ILaunchConfigurationDelegate
|
||||
{
|
||||
@Override
|
||||
public void launch(ILaunchConfiguration configuration,
|
||||
String mode,
|
||||
ILaunch launch,
|
||||
IProgressMonitor monitor) throws CoreException
|
||||
{
|
||||
Set<String> modes = new HashSet<String>();
|
||||
modes.add(ILaunchManager.RUN_MODE);
|
||||
ILaunchDelegate delegate = configuration.getPreferredDelegate(modes);
|
||||
ILaunchConfigurationDelegate launchdelegate = delegate.getDelegate();
|
||||
launchdelegate.launch(configuration,
|
||||
ILaunchManager.RUN_MODE,
|
||||
launch,
|
||||
new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package intrace.eclipse.actions;
|
||||
|
||||
import org.eclipse.debug.ui.actions.AbstractLaunchToolbarAction;
|
||||
|
||||
public class InTraceToolbarAction extends AbstractLaunchToolbarAction
|
||||
{
|
||||
|
||||
public InTraceToolbarAction()
|
||||
{
|
||||
super("intrace.eclipse.launchGroup.InTrace");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package intrace.eclipse.ui.launching;
|
||||
|
||||
import org.eclipse.debug.ui.ILaunchShortcut;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
|
||||
public class InTraceLaunchShortcut implements ILaunchShortcut
|
||||
{
|
||||
|
||||
// Need to do most of the same as
|
||||
// org.eclipse.jdt.internal.debug.ui.launcher.JavaApplicationLaunchShortcut
|
||||
|
||||
@Override
|
||||
public void launch(ISelection selection, String mode)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(IEditorPart editor, String mode)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -128,7 +128,13 @@
|
|||
<fileset dir="./build/tmp" includes="intrace-ui-wrapper.jar" />
|
||||
<fileset dir="./lib" includes="swt-*.jar" />
|
||||
<zipfileset excludes="META-INF/*.MF" src="lib/jar-in-jar-loader.jar"/>
|
||||
</jarjar>
|
||||
</jarjar>
|
||||
|
||||
<!-- UI Library -->
|
||||
<jar jarfile="./build/jars/intrace-ui-helper.jar">
|
||||
<fileset dir="./build/classes" includes="**/shared/*.class" />
|
||||
<fileset dir="./build/classes" includes="**/client/gui/helper/*.class" />
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="test" description="Run Tests" depends="build" >
|
||||
|
|
|
|||
|
|
@ -38,18 +38,23 @@ import org.eclipse.swt.widgets.Shell;
|
|||
import org.eclipse.swt.widgets.TabFolder;
|
||||
import org.eclipse.swt.widgets.TabItem;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.intrace.client.gui.PatternInputWindow.PatternInputCallback;
|
||||
import org.intrace.client.gui.helper.Connection;
|
||||
import org.intrace.client.gui.helper.Connection.ConnectState;
|
||||
import org.intrace.client.gui.helper.Connection.ISocketCallback;
|
||||
import org.intrace.client.gui.helper.ControlConnectionThread;
|
||||
import org.intrace.client.gui.helper.ControlConnectionThread.IControlConnectionListener;
|
||||
import org.intrace.client.gui.helper.NetworkDataReceiverThread;
|
||||
import org.intrace.client.gui.helper.ParsedSettingsData;
|
||||
import org.intrace.client.gui.helper.PatternInputWindow;
|
||||
import org.intrace.client.gui.helper.StatusUpdater;
|
||||
import org.intrace.client.gui.helper.TraceFilterThread;
|
||||
import org.intrace.client.gui.helper.NetworkDataReceiverThread.INetworkOutputConfig;
|
||||
import org.intrace.client.gui.helper.PatternInputWindow.PatternInputCallback;
|
||||
import org.intrace.client.gui.helper.TraceFilterThread.TraceFilterProgressHandler;
|
||||
import org.intrace.client.gui.helper.TraceFilterThread.TraceTextHandler;
|
||||
import org.intrace.shared.AgentConfigConstants;
|
||||
|
||||
public class TraceWindow
|
||||
public class TraceWindow implements ISocketCallback, IControlConnectionListener
|
||||
{
|
||||
public static String NEWLINE = System.getProperty("line.separator");
|
||||
|
||||
|
|
@ -202,7 +207,7 @@ public class TraceWindow
|
|||
{
|
||||
connectionState = ConnectState.CONNECTING;
|
||||
updateUIStateSameThread();
|
||||
Connection.connectToAgent(traceDialogRef, sWindow, addressInput
|
||||
Connection.connectToAgent(thisWindow, sWindow, addressInput
|
||||
.getText(), portInput.getText(), connectStatus);
|
||||
} else if (connectionState == ConnectState.CONNECTED)
|
||||
{
|
||||
|
|
@ -591,6 +596,7 @@ public class TraceWindow
|
|||
networkOutput = new Button(composite, SWT.CHECK);
|
||||
networkOutput.setText(ClientStrings.ENABLE_NETWORK_OUTPUT);
|
||||
networkOutput.setLayoutData("grow");
|
||||
networkOutput.setSelection(true);
|
||||
|
||||
Button autoScrollBtn = new Button(composite, SWT.CHECK);
|
||||
autoScrollBtn.setText(ClientStrings.AUTO_SCROLL);
|
||||
|
|
@ -1155,13 +1161,7 @@ public class TraceWindow
|
|||
}
|
||||
|
||||
// Window ref
|
||||
private final TraceWindow traceDialogRef = this;
|
||||
|
||||
// State
|
||||
private enum ConnectState
|
||||
{
|
||||
DISCONNECTED_ERR, DISCONNECTED, CONNECTING, CONNECTED
|
||||
}
|
||||
private final TraceWindow thisWindow = this;
|
||||
|
||||
private ConnectState connectionState = ConnectState.DISCONNECTED;
|
||||
|
||||
|
|
@ -1183,7 +1183,7 @@ public class TraceWindow
|
|||
private Pattern oldExcludeFilterPattern = TraceFilterThread.MATCH_NONE;
|
||||
private boolean autoScroll = true;
|
||||
|
||||
public void setConnectionState(Socket socket)
|
||||
public void setSocket(Socket socket)
|
||||
{
|
||||
if (socket != null)
|
||||
{
|
||||
|
|
@ -1198,8 +1198,16 @@ public class TraceWindow
|
|||
int networkTracePort = Integer.parseInt(networkTracePortStr);
|
||||
try
|
||||
{
|
||||
INetworkOutputConfig config = new INetworkOutputConfig()
|
||||
{
|
||||
@Override
|
||||
public boolean isNetOutputEnabled()
|
||||
{
|
||||
return settingsData.netOutEnabled;
|
||||
}
|
||||
};
|
||||
networkTraceThread = new NetworkDataReceiverThread(remoteAddress,
|
||||
networkTracePort, traceDialogRef, textOutputTab.filterThread);
|
||||
networkTracePort, config, textOutputTab.filterThread);
|
||||
networkTraceThread.start();
|
||||
} catch (IOException ex)
|
||||
{
|
||||
|
|
@ -1214,11 +1222,6 @@ public class TraceWindow
|
|||
updateUIState();
|
||||
}
|
||||
|
||||
public ParsedSettingsData getSettings()
|
||||
{
|
||||
return settingsData;
|
||||
}
|
||||
|
||||
public void disconnect()
|
||||
{
|
||||
if (controlThread != null)
|
||||
|
|
|
|||
|
|
@ -6,11 +6,21 @@ import java.net.Socket;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.intrace.client.gui.TraceWindow;
|
||||
|
||||
public class Connection
|
||||
{
|
||||
public static void connectToAgent(final TraceWindow owningWindow,
|
||||
// State
|
||||
public enum ConnectState
|
||||
{
|
||||
DISCONNECTED_ERR, DISCONNECTED, CONNECTING, CONNECTED
|
||||
}
|
||||
|
||||
public static interface ISocketCallback
|
||||
{
|
||||
public void setSocket(Socket socket);
|
||||
}
|
||||
|
||||
public static void connectToAgent(final ISocketCallback owningWindow,
|
||||
final Shell sShell, final String host,
|
||||
final String port,
|
||||
final StatusUpdater statusUpdater)
|
||||
|
|
@ -19,13 +29,13 @@ public class Connection
|
|||
{
|
||||
displayError(sShell, "Please enter an address");
|
||||
statusUpdater.setStatusText("Error: Please enter an address");
|
||||
owningWindow.setConnectionState(null);
|
||||
owningWindow.setSocket(null);
|
||||
}
|
||||
else if (port.length() == 0)
|
||||
{
|
||||
displayError(sShell, "Please enter a port");
|
||||
statusUpdater.setStatusText("Error: Please enter a port");
|
||||
owningWindow.setConnectionState(null);
|
||||
owningWindow.setSocket(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -40,12 +50,12 @@ public class Connection
|
|||
{
|
||||
socket.connect(new InetSocketAddress(host, Integer.valueOf(port)));
|
||||
statusUpdater.setStatusText("Connected");
|
||||
owningWindow.setConnectionState(socket);
|
||||
owningWindow.setSocket(socket);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
statusUpdater.setStatusText("Error: " + e.toString());
|
||||
owningWindow.setConnectionState(null);
|
||||
owningWindow.setSocket(null);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
|
|
|||
|
|
@ -9,21 +9,28 @@ import java.util.Map;
|
|||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.intrace.client.gui.TraceWindow;
|
||||
import org.intrace.shared.AgentConfigConstants;
|
||||
|
||||
public class ControlConnectionThread implements Runnable
|
||||
{
|
||||
public static interface IControlConnectionListener
|
||||
{
|
||||
public void setProgress(Map<String,String> progress);
|
||||
public void setStatus(Map<String,String> progress);
|
||||
public void setConfig(Map<String,String> progress);
|
||||
public void disconnect();
|
||||
}
|
||||
|
||||
private final Socket socket;
|
||||
private final TraceWindow window;
|
||||
private final IControlConnectionListener listener;
|
||||
private final BlockingQueue<String> incomingMessages = new LinkedBlockingQueue<String>();
|
||||
private final BlockingQueue<String> outgoingMessages = new LinkedBlockingQueue<String>();
|
||||
private final ControlConnectionSenderThread senderThread = new ControlConnectionSenderThread();
|
||||
private Thread sendThread;
|
||||
|
||||
public ControlConnectionThread(Socket socket, TraceWindow devTraceWindow)
|
||||
public ControlConnectionThread(Socket socket, IControlConnectionListener listener)
|
||||
{
|
||||
this.window = devTraceWindow;
|
||||
this.listener = listener;
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
|
|
@ -67,15 +74,15 @@ public class ControlConnectionThread implements Runnable
|
|||
Map<String, String> map = (Map<String, String>) receivedMessage;
|
||||
if (map.containsKey(AgentConfigConstants.NUM_PROGRESS_ID))
|
||||
{
|
||||
window.setProgress(map);
|
||||
listener.setProgress(map);
|
||||
}
|
||||
else if (map.containsKey(AgentConfigConstants.NUM_STATUS_ID))
|
||||
{
|
||||
window.setStatus(map);
|
||||
listener.setStatus(map);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.setConfig(map);
|
||||
listener.setConfig(map);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -91,7 +98,7 @@ public class ControlConnectionThread implements Runnable
|
|||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
window.disconnect();
|
||||
listener.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +148,7 @@ public class ControlConnectionThread implements Runnable
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
window.disconnect();
|
||||
listener.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,22 @@ import java.net.InetAddress;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.intrace.client.gui.TraceWindow;
|
||||
|
||||
public class NetworkDataReceiverThread implements Runnable
|
||||
{
|
||||
public static interface INetworkOutputConfig
|
||||
{
|
||||
public boolean isNetOutputEnabled();
|
||||
}
|
||||
|
||||
private final Socket traceSocket;
|
||||
private final TraceWindow window;
|
||||
private final INetworkOutputConfig outputConfig;
|
||||
private final TraceFilterThread traceThread;
|
||||
|
||||
public NetworkDataReceiverThread(InetAddress address, int networkTracePort,
|
||||
TraceWindow traceDialogRef, TraceFilterThread traceThread)
|
||||
INetworkOutputConfig outputConfig, TraceFilterThread traceThread)
|
||||
throws IOException
|
||||
{
|
||||
this.window = traceDialogRef;
|
||||
this.outputConfig = outputConfig;
|
||||
this.traceThread = traceThread;
|
||||
traceSocket = new Socket();
|
||||
traceSocket.connect(new InetSocketAddress(address, networkTracePort));
|
||||
|
|
@ -48,7 +51,7 @@ public class NetworkDataReceiverThread implements Runnable
|
|||
String traceLine = (String) data;
|
||||
if (!"NOOP".equals(traceLine))
|
||||
{
|
||||
if (window.getSettings().netOutEnabled)
|
||||
if (outputConfig.isNetOutputEnabled())
|
||||
{
|
||||
traceThread.addTraceLine(traceLine);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,341 +1,340 @@
|
|||
package org.intrace.client.gui;
|
||||
|
||||
import net.miginfocom.swt.MigLayout;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.intrace.client.gui.helper.TraceFilterThread;
|
||||
|
||||
public class PatternInputWindow
|
||||
{
|
||||
public final Shell sWindow;
|
||||
|
||||
private final PatternInputCallback callback;
|
||||
|
||||
private final PatternInput includePatterns;
|
||||
|
||||
private final PatternInput excludePatterns;
|
||||
|
||||
private final SaveCancelButtons saveCancelButtons;
|
||||
|
||||
public PatternInputWindow(String windowTitle, String helpText,
|
||||
PatternInputCallback callback, String initIncludePatterns,
|
||||
String initExcludePatterns)
|
||||
{
|
||||
this.callback = callback;
|
||||
MigLayout windowLayout = new MigLayout("fill", "[grow][100][100][grow]",
|
||||
"[grow][grow][25]");
|
||||
if (initExcludePatterns == null)
|
||||
{
|
||||
windowLayout.setRowConstraints("[grow][25]");
|
||||
}
|
||||
|
||||
sWindow = new Shell(SWT.APPLICATION_MODAL | SWT.CLOSE | SWT.TITLE
|
||||
| SWT.RESIZE);
|
||||
sWindow.setText(windowTitle);
|
||||
sWindow.setLayout(windowLayout);
|
||||
if (initExcludePatterns != null)
|
||||
{
|
||||
sWindow.setSize(new Point(400, 600));
|
||||
sWindow.setMinimumSize(new Point(400, 600));
|
||||
}
|
||||
else
|
||||
{
|
||||
sWindow.setSize(new Point(400, 300));
|
||||
sWindow.setMinimumSize(new Point(400, 300));
|
||||
}
|
||||
|
||||
includePatterns = new PatternInput(sWindow, "Include", helpText,
|
||||
initIncludePatterns);
|
||||
if (initExcludePatterns != null)
|
||||
{
|
||||
excludePatterns = new PatternInput(sWindow, "Exclude", helpText,
|
||||
initExcludePatterns);
|
||||
}
|
||||
else
|
||||
{
|
||||
excludePatterns = null;
|
||||
}
|
||||
|
||||
saveCancelButtons = new SaveCancelButtons(sWindow);
|
||||
|
||||
}
|
||||
|
||||
private class PatternInput
|
||||
{
|
||||
private final NewPattern newPattern;
|
||||
private final PatternList patternList;
|
||||
|
||||
public PatternInput(Composite parent, String patternText, String helpText,
|
||||
String initPatterns)
|
||||
{
|
||||
Group patternInputGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
|
||||
MigLayout connGroupLayout = new MigLayout("fill", "[grow]", "[25][grow]");
|
||||
patternInputGroup.setLayout(connGroupLayout);
|
||||
patternInputGroup.setText(patternText);
|
||||
patternInputGroup.setLayoutData("grow,wrap,spanx");
|
||||
|
||||
newPattern = new NewPattern(patternInputGroup, helpText);
|
||||
patternList = new PatternList(patternInputGroup, initPatterns);
|
||||
}
|
||||
|
||||
private class NewPattern
|
||||
{
|
||||
private final Text patternInput;
|
||||
|
||||
private NewPattern(Composite parent, String helpText)
|
||||
{
|
||||
Group newPatternGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
|
||||
newPatternGroup.setLayoutData("grow,wrap");
|
||||
MigLayout newPatternLayout = new MigLayout("fill", "[grow][60]");
|
||||
newPatternGroup.setLayout(newPatternLayout);
|
||||
newPatternGroup.setText("New Pattern");
|
||||
|
||||
patternInput = new Text(newPatternGroup, SWT.BORDER);
|
||||
patternInput.setLayoutData("grow");
|
||||
|
||||
final Button addButton = new Button(newPatternGroup, SWT.PUSH);
|
||||
addButton.setText("Add");
|
||||
addButton.setAlignment(SWT.CENTER);
|
||||
addButton.setLayoutData("grow");
|
||||
addButton.setToolTipText("Help: " + helpText);
|
||||
|
||||
Button removeButton = new Button(newPatternGroup, SWT.PUSH);
|
||||
removeButton.setText("Remove");
|
||||
removeButton.setAlignment(SWT.CENTER);
|
||||
removeButton.setLayoutData("grow,wrap");
|
||||
|
||||
addButton
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0)
|
||||
{
|
||||
patternList.addItem();
|
||||
}
|
||||
});
|
||||
removeButton
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0)
|
||||
{
|
||||
patternList.removeItem();
|
||||
}
|
||||
});
|
||||
patternInput
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent arg0)
|
||||
{
|
||||
patternList.addItem();
|
||||
saveCancelButtons.saveButton.setFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private class PatternList
|
||||
{
|
||||
private final List patternSet;
|
||||
|
||||
private PatternList(Composite parent, String initPatterns)
|
||||
{
|
||||
Group patternGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
|
||||
patternGroup.setLayoutData("grow");
|
||||
MigLayout patternLayout = new MigLayout("fill");
|
||||
patternGroup.setLayout(patternLayout);
|
||||
patternGroup.setText("Patterns (Double click to Edit)");
|
||||
|
||||
patternSet = new List(patternGroup, SWT.BORDER);
|
||||
patternSet.setLayoutData("grow");
|
||||
|
||||
patternSet.addMouseListener(new org.eclipse.swt.events.MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseDoubleClick(MouseEvent mouseevent)
|
||||
{
|
||||
editItem();
|
||||
}
|
||||
});
|
||||
|
||||
parsePatternSet(initPatterns);
|
||||
}
|
||||
|
||||
private void parsePatternSet(String initPattern)
|
||||
{
|
||||
if (initPattern.indexOf("|") > -1)
|
||||
{
|
||||
String[] initPatterns = initPattern.split("\\|");
|
||||
for (String pattern : initPatterns)
|
||||
{
|
||||
parsePattern(pattern);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parsePattern(initPattern);
|
||||
}
|
||||
}
|
||||
|
||||
private void parsePattern(String pattern)
|
||||
{
|
||||
if ((pattern != null) && (pattern.length() > 0))
|
||||
{
|
||||
pattern = pattern.replace(".*", "*").replace("\\.", ".");
|
||||
addItem(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
private void addItem()
|
||||
{
|
||||
String newItem = newPattern.patternInput.getText();
|
||||
addItem(newItem);
|
||||
newPattern.patternInput.setText("");
|
||||
}
|
||||
|
||||
private void addItem(String newItem)
|
||||
{
|
||||
if (!newItem.equals("")
|
||||
&& !newItem.equals(TraceFilterThread.MATCH_NONE.pattern()))
|
||||
{
|
||||
boolean addItem = true;
|
||||
for (String item : patternSet.getItems())
|
||||
{
|
||||
if (item.equals(newItem))
|
||||
{
|
||||
addItem = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (addItem)
|
||||
{
|
||||
patternSet.add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeItem()
|
||||
{
|
||||
int[] selectedItems = patternSet.getSelectionIndices();
|
||||
|
||||
if (selectedItems.length == 1)
|
||||
{
|
||||
patternSet.remove(selectedItems[0]);
|
||||
}
|
||||
else if (newPattern.patternInput.getText().length() > 0)
|
||||
{
|
||||
newPattern.patternInput.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
private void editItem()
|
||||
{
|
||||
int[] selectedItems = patternSet.getSelectionIndices();
|
||||
|
||||
if (selectedItems.length == 1)
|
||||
{
|
||||
newPattern.patternInput.setText(patternSet.getItem(selectedItems[0]));
|
||||
patternSet.remove(selectedItems[0]);
|
||||
newPattern.patternInput.setFocus();
|
||||
newPattern.patternInput
|
||||
.setSelection(newPattern.patternInput
|
||||
.getText()
|
||||
.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getPattern()
|
||||
{
|
||||
StringBuffer pattern = new StringBuffer("");
|
||||
String patternStr = pattern.toString();
|
||||
boolean gotPattern = false;
|
||||
|
||||
String newPatternStr = newPattern.patternInput.getText();
|
||||
if (newPatternStr.length() > 0)
|
||||
{
|
||||
pattern.append(newPatternStr.replace(".", "\\.").replace("*", ".*"));
|
||||
pattern.append("|");
|
||||
gotPattern = true;
|
||||
}
|
||||
|
||||
String[] items = patternList.patternSet.getItems();
|
||||
if (items.length > 0)
|
||||
{
|
||||
for (String item : items)
|
||||
{
|
||||
pattern.append(item.replace(".", "\\.").replace("*", ".*"));
|
||||
pattern.append("|");
|
||||
}
|
||||
gotPattern = true;
|
||||
}
|
||||
|
||||
if (gotPattern)
|
||||
{
|
||||
patternStr = pattern.toString();
|
||||
patternStr = patternStr.substring(0, patternStr.length() - 1);
|
||||
}
|
||||
|
||||
return patternStr;
|
||||
}
|
||||
}
|
||||
|
||||
private class SaveCancelButtons
|
||||
{
|
||||
final Button saveButton;
|
||||
|
||||
private SaveCancelButtons(Composite sParent)
|
||||
{
|
||||
saveButton = new Button(sParent, SWT.PUSH);
|
||||
saveButton.setText("Apply Changes");
|
||||
saveButton.setAlignment(SWT.CENTER);
|
||||
saveButton.setLayoutData("skip,grow");
|
||||
|
||||
Button discardButton = new Button(sParent, SWT.PUSH);
|
||||
discardButton.setText("Discard Changes");
|
||||
discardButton.setAlignment(SWT.CENTER);
|
||||
discardButton.setLayoutData("grow");
|
||||
|
||||
saveButton
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0)
|
||||
{
|
||||
callback.setIncludePattern(includePatterns.getPattern());
|
||||
if (excludePatterns != null)
|
||||
{
|
||||
callback.setExcludePattern(excludePatterns.getPattern());
|
||||
}
|
||||
sWindow.close();
|
||||
}
|
||||
});
|
||||
discardButton
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0)
|
||||
{
|
||||
sWindow.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static interface PatternInputCallback
|
||||
{
|
||||
public void setIncludePattern(String newIncludePattern);
|
||||
|
||||
public void setExcludePattern(String newExcludePattern);
|
||||
}
|
||||
}
|
||||
package org.intrace.client.gui.helper;
|
||||
|
||||
import net.miginfocom.swt.MigLayout;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
public class PatternInputWindow
|
||||
{
|
||||
public final Shell sWindow;
|
||||
|
||||
private final PatternInputCallback callback;
|
||||
|
||||
private final PatternInput includePatterns;
|
||||
|
||||
private final PatternInput excludePatterns;
|
||||
|
||||
private final SaveCancelButtons saveCancelButtons;
|
||||
|
||||
public PatternInputWindow(String windowTitle, String helpText,
|
||||
PatternInputCallback callback, String initIncludePatterns,
|
||||
String initExcludePatterns)
|
||||
{
|
||||
this.callback = callback;
|
||||
MigLayout windowLayout = new MigLayout("fill", "[grow][100][100][grow]",
|
||||
"[grow][grow][25]");
|
||||
if (initExcludePatterns == null)
|
||||
{
|
||||
windowLayout.setRowConstraints("[grow][25]");
|
||||
}
|
||||
|
||||
sWindow = new Shell(SWT.APPLICATION_MODAL | SWT.CLOSE | SWT.TITLE
|
||||
| SWT.RESIZE);
|
||||
sWindow.setText(windowTitle);
|
||||
sWindow.setLayout(windowLayout);
|
||||
if (initExcludePatterns != null)
|
||||
{
|
||||
sWindow.setSize(new Point(400, 600));
|
||||
sWindow.setMinimumSize(new Point(400, 600));
|
||||
}
|
||||
else
|
||||
{
|
||||
sWindow.setSize(new Point(400, 300));
|
||||
sWindow.setMinimumSize(new Point(400, 300));
|
||||
}
|
||||
|
||||
includePatterns = new PatternInput(sWindow, "Include", helpText,
|
||||
initIncludePatterns);
|
||||
if (initExcludePatterns != null)
|
||||
{
|
||||
excludePatterns = new PatternInput(sWindow, "Exclude", helpText,
|
||||
initExcludePatterns);
|
||||
}
|
||||
else
|
||||
{
|
||||
excludePatterns = null;
|
||||
}
|
||||
|
||||
saveCancelButtons = new SaveCancelButtons(sWindow);
|
||||
|
||||
}
|
||||
|
||||
private class PatternInput
|
||||
{
|
||||
private final NewPattern newPattern;
|
||||
private final PatternList patternList;
|
||||
|
||||
public PatternInput(Composite parent, String patternText, String helpText,
|
||||
String initPatterns)
|
||||
{
|
||||
Group patternInputGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
|
||||
MigLayout connGroupLayout = new MigLayout("fill", "[grow]", "[25][grow]");
|
||||
patternInputGroup.setLayout(connGroupLayout);
|
||||
patternInputGroup.setText(patternText);
|
||||
patternInputGroup.setLayoutData("grow,wrap,spanx");
|
||||
|
||||
newPattern = new NewPattern(patternInputGroup, helpText);
|
||||
patternList = new PatternList(patternInputGroup, initPatterns);
|
||||
}
|
||||
|
||||
private class NewPattern
|
||||
{
|
||||
private final Text patternInput;
|
||||
|
||||
private NewPattern(Composite parent, String helpText)
|
||||
{
|
||||
Group newPatternGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
|
||||
newPatternGroup.setLayoutData("grow,wrap");
|
||||
MigLayout newPatternLayout = new MigLayout("fill", "[grow][60]");
|
||||
newPatternGroup.setLayout(newPatternLayout);
|
||||
newPatternGroup.setText("New Pattern");
|
||||
|
||||
patternInput = new Text(newPatternGroup, SWT.BORDER);
|
||||
patternInput.setLayoutData("grow");
|
||||
|
||||
final Button addButton = new Button(newPatternGroup, SWT.PUSH);
|
||||
addButton.setText("Add");
|
||||
addButton.setAlignment(SWT.CENTER);
|
||||
addButton.setLayoutData("grow");
|
||||
addButton.setToolTipText("Help: " + helpText);
|
||||
|
||||
Button removeButton = new Button(newPatternGroup, SWT.PUSH);
|
||||
removeButton.setText("Remove");
|
||||
removeButton.setAlignment(SWT.CENTER);
|
||||
removeButton.setLayoutData("grow,wrap");
|
||||
|
||||
addButton
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0)
|
||||
{
|
||||
patternList.addItem();
|
||||
}
|
||||
});
|
||||
removeButton
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0)
|
||||
{
|
||||
patternList.removeItem();
|
||||
}
|
||||
});
|
||||
patternInput
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent arg0)
|
||||
{
|
||||
patternList.addItem();
|
||||
saveCancelButtons.saveButton.setFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private class PatternList
|
||||
{
|
||||
private final List patternSet;
|
||||
|
||||
private PatternList(Composite parent, String initPatterns)
|
||||
{
|
||||
Group patternGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
|
||||
patternGroup.setLayoutData("grow");
|
||||
MigLayout patternLayout = new MigLayout("fill");
|
||||
patternGroup.setLayout(patternLayout);
|
||||
patternGroup.setText("Patterns (Double click to Edit)");
|
||||
|
||||
patternSet = new List(patternGroup, SWT.BORDER);
|
||||
patternSet.setLayoutData("grow");
|
||||
|
||||
patternSet.addMouseListener(new org.eclipse.swt.events.MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseDoubleClick(MouseEvent mouseevent)
|
||||
{
|
||||
editItem();
|
||||
}
|
||||
});
|
||||
|
||||
parsePatternSet(initPatterns);
|
||||
}
|
||||
|
||||
private void parsePatternSet(String initPattern)
|
||||
{
|
||||
if (initPattern.indexOf("|") > -1)
|
||||
{
|
||||
String[] initPatterns = initPattern.split("\\|");
|
||||
for (String pattern : initPatterns)
|
||||
{
|
||||
parsePattern(pattern);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parsePattern(initPattern);
|
||||
}
|
||||
}
|
||||
|
||||
private void parsePattern(String pattern)
|
||||
{
|
||||
if ((pattern != null) && (pattern.length() > 0))
|
||||
{
|
||||
pattern = pattern.replace(".*", "*").replace("\\.", ".");
|
||||
addItem(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
private void addItem()
|
||||
{
|
||||
String newItem = newPattern.patternInput.getText();
|
||||
addItem(newItem);
|
||||
newPattern.patternInput.setText("");
|
||||
}
|
||||
|
||||
private void addItem(String newItem)
|
||||
{
|
||||
if (!newItem.equals("")
|
||||
&& !newItem.equals(TraceFilterThread.MATCH_NONE.pattern()))
|
||||
{
|
||||
boolean addItem = true;
|
||||
for (String item : patternSet.getItems())
|
||||
{
|
||||
if (item.equals(newItem))
|
||||
{
|
||||
addItem = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (addItem)
|
||||
{
|
||||
patternSet.add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeItem()
|
||||
{
|
||||
int[] selectedItems = patternSet.getSelectionIndices();
|
||||
|
||||
if (selectedItems.length == 1)
|
||||
{
|
||||
patternSet.remove(selectedItems[0]);
|
||||
}
|
||||
else if (newPattern.patternInput.getText().length() > 0)
|
||||
{
|
||||
newPattern.patternInput.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
private void editItem()
|
||||
{
|
||||
int[] selectedItems = patternSet.getSelectionIndices();
|
||||
|
||||
if (selectedItems.length == 1)
|
||||
{
|
||||
newPattern.patternInput.setText(patternSet.getItem(selectedItems[0]));
|
||||
patternSet.remove(selectedItems[0]);
|
||||
newPattern.patternInput.setFocus();
|
||||
newPattern.patternInput
|
||||
.setSelection(newPattern.patternInput
|
||||
.getText()
|
||||
.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getPattern()
|
||||
{
|
||||
StringBuffer pattern = new StringBuffer("");
|
||||
String patternStr = pattern.toString();
|
||||
boolean gotPattern = false;
|
||||
|
||||
String newPatternStr = newPattern.patternInput.getText();
|
||||
if (newPatternStr.length() > 0)
|
||||
{
|
||||
pattern.append(newPatternStr.replace(".", "\\.").replace("*", ".*"));
|
||||
pattern.append("|");
|
||||
gotPattern = true;
|
||||
}
|
||||
|
||||
String[] items = patternList.patternSet.getItems();
|
||||
if (items.length > 0)
|
||||
{
|
||||
for (String item : items)
|
||||
{
|
||||
pattern.append(item.replace(".", "\\.").replace("*", ".*"));
|
||||
pattern.append("|");
|
||||
}
|
||||
gotPattern = true;
|
||||
}
|
||||
|
||||
if (gotPattern)
|
||||
{
|
||||
patternStr = pattern.toString();
|
||||
patternStr = patternStr.substring(0, patternStr.length() - 1);
|
||||
}
|
||||
|
||||
return patternStr;
|
||||
}
|
||||
}
|
||||
|
||||
private class SaveCancelButtons
|
||||
{
|
||||
final Button saveButton;
|
||||
|
||||
private SaveCancelButtons(Composite sParent)
|
||||
{
|
||||
saveButton = new Button(sParent, SWT.PUSH);
|
||||
saveButton.setText("Apply Changes");
|
||||
saveButton.setAlignment(SWT.CENTER);
|
||||
saveButton.setLayoutData("skip,grow");
|
||||
|
||||
Button discardButton = new Button(sParent, SWT.PUSH);
|
||||
discardButton.setText("Discard Changes");
|
||||
discardButton.setAlignment(SWT.CENTER);
|
||||
discardButton.setLayoutData("grow");
|
||||
|
||||
saveButton
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0)
|
||||
{
|
||||
callback.setIncludePattern(includePatterns.getPattern());
|
||||
if (excludePatterns != null)
|
||||
{
|
||||
callback.setExcludePattern(excludePatterns.getPattern());
|
||||
}
|
||||
sWindow.close();
|
||||
}
|
||||
});
|
||||
discardButton
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
|
||||
{
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0)
|
||||
{
|
||||
sWindow.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static interface PatternInputCallback
|
||||
{
|
||||
public void setIncludePattern(String newIncludePattern);
|
||||
|
||||
public void setExcludePattern(String newExcludePattern);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ public class TraceSettings
|
|||
|
||||
private boolean stdoutTraceOutputEnabled = false;
|
||||
private boolean fileTraceOutputEnabled = false;
|
||||
private boolean netTraceOutputEnabled = false;
|
||||
private boolean netTraceOutputEnabled = true;
|
||||
private File file1 = new File("trc1.txt");
|
||||
private File file2 = new File("trc2.txt");
|
||||
private PrintWriter file1TraceWriter = null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue