├── .gitignore
├── .mvn
└── extensions.xml
├── LICENSE
├── README.md
├── ant.macros.xml
├── ant.properties
├── build.xml
├── eclipse.sdk
├── 3.2
│ └── sdk
│ │ ├── com.ibm.icu_3.4.5.jar
│ │ ├── org.eclipse.core.commands_3.2.0.jar
│ │ ├── org.eclipse.core.contenttype_3.2.0.jar
│ │ ├── org.eclipse.core.expressions_3.2.1.jar
│ │ ├── org.eclipse.core.filebuffers_3.2.0.jar
│ │ ├── org.eclipse.core.jobs_3.2.0.jar
│ │ ├── org.eclipse.core.resources_3.2.0.jar
│ │ ├── org.eclipse.core.runtime.compatibility.auth_3.2.0.jar
│ │ ├── org.eclipse.core.runtime_3.2.0.jar
│ │ ├── org.eclipse.equinox.common_3.2.0.jar
│ │ ├── org.eclipse.equinox.preferences_3.2.1.jar
│ │ ├── org.eclipse.equinox.registry_3.2.1.jar
│ │ ├── org.eclipse.help_3.2.1.jar
│ │ ├── org.eclipse.jface.databinding_1.0.0.jar
│ │ ├── org.eclipse.jface.text_3.2.0.jar
│ │ ├── org.eclipse.jface_3.2.1.jar
│ │ ├── org.eclipse.osgi_3.2.1.jar
│ │ ├── org.eclipse.rcp_3.2.0.jar
│ │ ├── org.eclipse.swt.win32.win32.x86_3.2.1.jar
│ │ ├── org.eclipse.swt_3.2.1.jar
│ │ ├── org.eclipse.text_3.2.0.jar
│ │ ├── org.eclipse.ui.editors_3.2.0.jar
│ │ ├── org.eclipse.ui.ide_3.2.0.jar
│ │ ├── org.eclipse.ui.workbench.texteditor_3.2.0.jar
│ │ ├── org.eclipse.ui.workbench_3.2.1.jar
│ │ ├── org.eclipse.ui_3.2.1.jar
│ │ └── org.eclipse.update.configurator_3.2.1.jar
└── 3.3
│ ├── com.ibm.icu_3.4.5.jar
│ ├── commons-codec-1.3.jar
│ ├── commons-httpclient-3.1.jar
│ ├── commons-lang-2.3.jar
│ ├── commons-logging.jar
│ ├── org.eclipse.core.commands_3.3.0.I20070605-0010.jar
│ ├── org.eclipse.core.contenttype_3.2.0.jar
│ ├── org.eclipse.core.expressions_3.2.1.jar
│ ├── org.eclipse.core.filebuffers_3.2.0.jar
│ ├── org.eclipse.core.jobs_3.3.0.v20070423.jar
│ ├── org.eclipse.core.resources_3.3.0.v20070604.jar
│ ├── org.eclipse.core.runtime.compatibility.auth_3.2.0.jar
│ ├── org.eclipse.core.runtime_3.3.100.v20070530.jar
│ ├── org.eclipse.equinox.common_3.3.0.v20070426.jar
│ ├── org.eclipse.equinox.preferences_3.2.100.v20070522.jar
│ ├── org.eclipse.equinox.registry_3.3.0.v20070522.jar
│ ├── org.eclipse.help_3.2.1.jar
│ ├── org.eclipse.jface.databinding_1.0.0.jar
│ ├── org.eclipse.jface.text_3.3.0.v20070606-0010.jar
│ ├── org.eclipse.jface_3.3.0.I20070606-0010.jar
│ ├── org.eclipse.osgi_3.3.0.v20070530.jar
│ ├── org.eclipse.rcp_3.2.0.jar
│ ├── org.eclipse.swt.win32.win32.x86_3.3.0.v3346.jar
│ ├── org.eclipse.swt_3.3.0.v3346.jar
│ ├── org.eclipse.text_3.3.0.v20070606-0010.jar
│ ├── org.eclipse.ui.editors_3.2.0.jar
│ ├── org.eclipse.ui.ide_3.3.0.I20070620.jar
│ ├── org.eclipse.ui.workbench.texteditor_3.3.0.v20070606-0010.jar
│ ├── org.eclipse.ui.workbench_3.3.0.I20070608-1100.jar
│ ├── org.eclipse.ui_3.3.0.I20070614-0800.jar
│ └── org.eclipse.update.configurator_3.2.1.jar
├── http4e-Core
├── .classpath
├── .project
├── .settings
│ ├── org.eclipse.jdt.core.prefs
│ ├── org.eclipse.jdt.ui.prefs
│ └── org.eclipse.ltk.core.refactoring.prefs
├── META-INF
│ └── MANIFEST.MF
├── about.html
├── ant.project.xml
├── build.properties
├── icons
│ ├── assist-header.png
│ ├── assist-param.png
│ ├── assist-template.png
│ ├── blank16.gif
│ ├── browser.png
│ ├── delete.png
│ ├── file-open-dis.png
│ ├── file-open.png
│ ├── go.gif
│ ├── hex.gif
│ ├── hex.png
│ ├── json.png
│ ├── loading-small.gif
│ ├── loading-small.png
│ ├── logo.png
│ ├── logok.png
│ ├── pretty.png
│ ├── progress_stop_off.gif
│ ├── progress_stop_on.gif
│ ├── raw.png
│ ├── title-line.png
│ └── view-fullscreen.png
├── lib
│ ├── commons-codec-1.3.jar
│ ├── commons-httpclient-3.1-beta1-m.jar
│ ├── commons-lang-2.3.jar
│ ├── commons-logging.jar
│ ├── velocity-1.6.3-dep.jar
│ ├── velocity-1.6.3.jar
│ └── xom-1.2.4.jar
├── resources
│ ├── Info-Accept-Charset.properties
│ ├── Info-Accept-Language.properties
│ ├── Info-Content-Language.properties
│ ├── Info-Content-MD5.properties
│ ├── Info-Content-Type.properties
│ ├── Info-Headers.properties
│ ├── Info-Properties.rar
│ ├── cocoa-delete.vm
│ ├── cocoa-get.vm
│ ├── cocoa-post.vm
│ ├── cocoa-put.vm
│ ├── csharp.vm
│ ├── flex.vm
│ ├── headers-values.properties
│ ├── headers.properties
│ ├── http-runner-src.txt
│ ├── http4e-item.vm
│ ├── http4e-sessions.vm
│ ├── java.vm
│ ├── java3.vm
│ ├── jmx.vm
│ ├── js-jquery.vm
│ ├── js-prototype.vm
│ ├── js-xhr.vm
│ ├── oc.vm
│ ├── php.vm
│ ├── python.vm
│ ├── ruby.vm
│ └── vb.vm
└── src
│ └── app
│ ├── com
│ └── gargoylesoftware
│ │ └── htmlunit
│ │ └── ssl
│ │ ├── InsecureSSLProtocolSocketFactory.java
│ │ └── InsecureTrustManager.java
│ └── org
│ ├── apache
│ └── commons
│ │ └── httpclient
│ │ ├── CircularRedirectException.java
│ │ ├── HttpConnection.java
│ │ ├── HttpMethod.java
│ │ ├── HttpMethodBase.java
│ │ ├── HttpMethodDirector.java
│ │ └── contrib
│ │ ├── ssl
│ │ ├── AuthSSLInitializationError.java
│ │ ├── AuthSSLProtocolSocketFactory.java
│ │ ├── AuthSSLX509TrustManager.java
│ │ ├── EasySSLProtocolSocketFactory.java
│ │ ├── EasyX509TrustManager.java
│ │ ├── HostConfigurationWithHostFactory.java
│ │ ├── HostConfigurationWithStickyProtocol.java
│ │ ├── HttpClientSSLTest.java
│ │ ├── HttpHostFactory.java
│ │ ├── SocketFactoryWrapper.java
│ │ └── StrictSSLProtocolSocketFactory.java
│ │ └── utils
│ │ └── HttpMethodCloner.java
│ ├── eclipse
│ └── swt
│ │ ├── custom
│ │ ├── BalloonWindow.java
│ │ ├── CustomSeparator.java
│ │ ├── LiveSashForm.java
│ │ ├── UrbanSashForm.java
│ │ └── UrbanSashFormLayout.java
│ │ └── snippets
│ │ ├── Snippet163.java
│ │ ├── Snippet163old.java
│ │ ├── Snippet218.java
│ │ ├── Snippet222.java
│ │ ├── Snippet25.java
│ │ ├── Snippet331.java
│ │ └── Snippet332.java
│ ├── json
│ └── me
│ │ ├── Ch5CompletionEditor.java
│ │ ├── JSONArray.java
│ │ ├── JSONException.java
│ │ ├── JSONObject.java
│ │ ├── JSONString.java
│ │ ├── JSONStringer.java
│ │ ├── JSONTokener.java
│ │ ├── JSONWriter.java
│ │ ├── SWTHelloWorld.java
│ │ ├── SWTStyledTextExample.java
│ │ ├── Snippet320AutoCompleteExample.java
│ │ ├── StringWriter.java
│ │ └── test
│ │ ├── SyntaxData.java
│ │ ├── SyntaxManager2.java
│ │ ├── Test.java
│ │ └── Uutt.java
│ └── roussev
│ └── http4e
│ ├── ant
│ └── AntReader.java
│ ├── crypt
│ ├── CryptConstants.java
│ ├── CryptUtils.java
│ ├── EncryptFacade.java
│ ├── Errors.java
│ ├── HexUtils.java
│ ├── MiscUtils.java
│ ├── TestCrypt.java
│ ├── TestPublicPrivateKeys.java
│ └── depricated
│ │ ├── Qwe.java
│ │ └── Version.java
│ ├── editor
│ └── xml
│ │ ├── ColorManager.java
│ │ ├── IXMLColorConstants.java
│ │ ├── NonRuleBasedDamagerRepairer.java
│ │ ├── XMLConfiguration.java
│ │ ├── XMLDoubleClickStrategy.java
│ │ ├── XMLPartitioner.java
│ │ ├── XMLWhitespaceDetector.java
│ │ ├── contentassist
│ │ └── TagContentAssistProcessor.java
│ │ ├── format
│ │ ├── DefaultFormattingStrategy.java
│ │ ├── DocTypeFormattingStrategy.java
│ │ ├── PIFormattingStrategy.java
│ │ ├── TextFormattingStrategy.java
│ │ └── XMLFormattingStrategy.java
│ │ ├── rules
│ │ ├── CDataRule.java
│ │ ├── EscapedCharRule.java
│ │ ├── NonMatchingRule.java
│ │ ├── StartTagRule.java
│ │ └── XMLTextPredicateRule.java
│ │ ├── scanners
│ │ ├── CDataScanner.java
│ │ ├── XMLPartitionScanner.java
│ │ ├── XMLScanner.java
│ │ ├── XMLTagScanner.java
│ │ └── XMLTextScanner.java
│ │ └── xmlattribs
│ │ ├── XMLAttribute.java
│ │ ├── XMLElement.java
│ │ ├── XMLParser.java
│ │ ├── XMLTree.java
│ │ ├── XMLValidationError.java
│ │ └── XMLValidationErrorHandler.java
│ ├── httpclient
│ └── core
│ │ ├── CoreConstants.java
│ │ ├── CoreContext.java
│ │ ├── CoreImages.java
│ │ ├── CoreMessages.java
│ │ ├── CoreObjects.java
│ │ ├── ExceptionHandler.java
│ │ ├── client
│ │ ├── misc
│ │ │ ├── ApacheHttpListener.java
│ │ │ ├── ApacheOutputStream.java
│ │ │ ├── BusinessJob.java
│ │ │ ├── EclipseHttpJob.java
│ │ │ ├── HttpPerformer.java
│ │ │ ├── JobListener.java
│ │ │ └── JobRunner.java
│ │ ├── model
│ │ │ ├── AuthItem.java
│ │ │ ├── FolderModel.java
│ │ │ ├── Item.java
│ │ │ ├── ItemModel.java
│ │ │ ├── Model.java
│ │ │ ├── ModelEvent.java
│ │ │ ├── ModelListener.java
│ │ │ └── ProxyItem.java
│ │ └── view
│ │ │ ├── AnimatedGIFRunner.java
│ │ │ ├── Animator.java
│ │ │ ├── AttachManager.java
│ │ │ ├── BodyView.java
│ │ │ ├── ClipboardMenu.java
│ │ │ ├── ExecuteCommand.java
│ │ │ ├── ExecuteKeyListener.java
│ │ │ ├── FolderView.java
│ │ │ ├── HeaderView.java
│ │ │ ├── HexManager.java
│ │ │ ├── IControlView.java
│ │ │ ├── ItemState.java
│ │ │ ├── ItemView.java
│ │ │ ├── JSONLineStyler.java
│ │ │ ├── ParamTable.java
│ │ │ ├── ParamTableView.java
│ │ │ ├── ParamTextView.java
│ │ │ ├── ParamView.java
│ │ │ ├── ParameterizeTextView.java
│ │ │ ├── ParamsAttachManager.java
│ │ │ ├── PayloadMenu.java
│ │ │ ├── RequestView.java
│ │ │ ├── ResponseView.java
│ │ │ ├── SWTHelloWorld.java
│ │ │ ├── Utils.java
│ │ │ ├── ViewUtils.java
│ │ │ └── assist
│ │ │ ├── AssistConstants.java
│ │ │ ├── AssistUtils.java
│ │ │ ├── AstandaloneHEditor.java
│ │ │ ├── DocumentUtils.java
│ │ │ ├── HAssistInfoMap.java
│ │ │ ├── HCommentScanner.java
│ │ │ ├── HConfiguration.java
│ │ │ ├── HContentAssistProcessor.java
│ │ │ ├── HDefaultScanner.java
│ │ │ ├── HDoubleClickStrategy.java
│ │ │ ├── HPartitionScanner.java
│ │ │ ├── HValueScanner.java
│ │ │ ├── ModelTrackerListener.java
│ │ │ ├── MyAnnotationHover.java
│ │ │ ├── MyTextHover.java
│ │ │ ├── Tracker.java
│ │ │ └── WhitespaceDetector.java
│ │ ├── misc
│ │ ├── ColorManagerAdaptor.java
│ │ ├── CoreException.java
│ │ ├── LazyObjects.java
│ │ ├── ResourceCache.java
│ │ ├── Scripts.java
│ │ └── Styles.java
│ │ └── util
│ │ ├── BaseUtils.java
│ │ ├── FileCopy.java
│ │ ├── HttpBean.java
│ │ ├── HttpUtils.java
│ │ ├── JsonUtil.java
│ │ ├── JunkUtils.java
│ │ ├── ParseBean.java
│ │ ├── ParseUtils.java
│ │ ├── ResourceUtils.java
│ │ ├── ResponseReader.java
│ │ ├── StringPrintWriter.java
│ │ ├── SwtUtils.java
│ │ ├── Translator.java
│ │ └── shared
│ │ ├── ExportJavaViewer.java
│ │ ├── Exported.java
│ │ └── PrinterFacade.java
│ ├── java6
│ └── Properties6.java
│ └── jmeter
│ ├── Constants.java
│ ├── ExportSessionsTransformer.java
│ ├── ExportTemplateTransformer.java
│ ├── HttpToJmxTransformer.java
│ └── LiveHttpHeadersParser.java
├── http4e-Feature
├── .classpath
├── .project
├── ant.project.xml
├── build.properties
└── feature.xml
├── http4e-Plugin
├── .classpath
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.eclipse.jdt.ui.prefs
├── META-INF
│ └── MANIFEST.MF
├── about.html
├── about.ini
├── about.png
├── ant.project.xml
├── build.properties
├── icons
│ ├── auth.png
│ ├── auth_enabled copy.png
│ ├── auth_enabled.png
│ ├── auth_tab.png
│ ├── csharp.gif
│ ├── duplicate.gif
│ ├── export.gif
│ ├── flex.gif
│ ├── help.png
│ ├── import.gif
│ ├── java.png
│ ├── jmeter.gif
│ ├── jmeter.png
│ ├── js.gif
│ ├── logo-dialog.png
│ ├── logo.png
│ ├── magn.png
│ ├── oc.gif
│ ├── params.png
│ ├── php.gif
│ ├── print.png
│ ├── print_edit.gif
│ ├── proxy.png
│ ├── proxy_enabled copy.png
│ ├── proxy_enabled.png
│ ├── proxy_tab.png
│ ├── python.gif
│ ├── ruby.gif
│ ├── saveas_edit.gif
│ ├── tab-new.png
│ ├── vb.gif
│ └── views.png
├── lib
│ └── commons-lang-2.3.jar
├── plugin.xml
├── resources
│ ├── about.html
│ ├── export.html
│ ├── form2result.html
│ └── src.html
├── run.product.xml
└── src
│ └── app
│ └── org
│ └── roussev
│ └── http4e
│ └── httpclient
│ └── ui
│ ├── HdContentViewer.java
│ ├── HdPlugin.java
│ ├── HdViewPart.java
│ ├── UIConstants.java
│ ├── actions
│ ├── AboutDialog.java
│ ├── AddTabAction.java
│ ├── AuthDialog.java
│ ├── AuthenticationAction.java
│ ├── ConfigAction.java
│ ├── ConfigDialog.java
│ ├── DuplicateTabAction.java
│ ├── ExportAjaxJQueryAction.java
│ ├── ExportAjaxJSAction.java
│ ├── ExportAjaxPrototypeAction.java
│ ├── ExportCocoaAction.java
│ ├── ExportCsAction.java
│ ├── ExportDialog.java
│ ├── ExportEmptyAction.java
│ ├── ExportFlexAction.java
│ ├── ExportHTTP4eAction.java
│ ├── ExportJMeterAction.java
│ ├── ExportJavaHttp3Action.java
│ ├── ExportJavaHttp4Action.java
│ ├── ExportMenuAction.java
│ ├── ExportPHPAction.java
│ ├── ExportPythonAction.java
│ ├── ExportRubyAction.java
│ ├── ExportVbAction.java
│ ├── HdActionDelegate.java
│ ├── HdJavaEditorInput.java
│ ├── HelpAboutAction.java
│ ├── HelpDropDownAction.java
│ ├── ImportDialog.java
│ ├── ImportHTTP4eAction.java
│ ├── ImportLiveHttpHeadersAction.java
│ ├── ImportMenuAction.java
│ ├── ImportPacketAction.java
│ ├── ParameterizeAction.java
│ ├── ParameterizeDialog.java
│ ├── PrintAction.java
│ ├── ProxyAction.java
│ ├── ProxyDialog.java
│ ├── TabCloseAction.java
│ └── ToolsAction.java
│ ├── dialog
│ └── example
│ │ ├── DumbUser.java
│ │ ├── GetUserInput.java
│ │ ├── PrintDialogExample.java
│ │ └── ShowMyTitleAreaDialog.java
│ └── preferences
│ ├── HTTPClientPreferencePage.java
│ ├── PreferenceConstants.java
│ ├── PreferenceInitializer.java
│ ├── ProxyItemListEditor.java
│ └── SSLEditor.java
├── http4e-Site
├── category.xml
└── pom.xml
├── pom.xml
└── site.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /classes
2 | /.class
3 | /.build
4 |
5 | # maven stuff
6 | target
7 | .polyglot.build.properties
8 |
--------------------------------------------------------------------------------
/.mvn/extensions.xml:
--------------------------------------------------------------------------------
1 |
2 |
68 |
69 |
--------------------------------------------------------------------------------
/ant.properties:
--------------------------------------------------------------------------------
1 | ide.version=3.2
2 | product.version=5.0.12
3 | product.tar=http4e-eclipse-rest-http-client.tar
4 |
5 | project.feature=feature
6 | project.core=org.roussev.http4e.core
7 | project.plugin=org.roussev.http4e.ui
8 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
Default content type. Forms submitted with this content type must be URL encoded.
The control names/values are listed in the order they appear in the document. The name is separated from the value by '=' and name/value pairs are separated from each other by '&'
Should be used for submitting forms that contain files, non-ASCII data, and binary data.
It follows the rules of all multipart MIME data streams.
A "multipart/form-data" message contains a series of parts.
$httpBean.request
4 |
5 |
6 | $httpBean.response
7 |
8 |
9 |
--------------------------------------------------------------------------------
/http4e-Core/resources/http4e-sessions.vm:
--------------------------------------------------------------------------------
1 |
2 | 5 | | # | 6 |Method | 7 |Protocol | 8 |Host | 9 |URL | 10 |Body | 11 |Content-Type | 12 |
---|---|---|---|---|---|---|---|
View | 17 |$httpBean.id | 18 |$httpBean.method | 19 |$httpBean.protocol | 20 |$httpBean.domain | 21 |$httpBean.path | 22 |$httpBean.bodyShort | 23 |$httpBean.contentType | 24 |
34 | * Signals fatal error in initialization of {@link AuthSSLProtocolSocketFactory}. 35 | *
36 | * 37 | * @author Oleg Kalnichevski 38 | * 39 | *40 | * DISCLAIMER: HttpClient developers DO NOT actively support this component. 41 | * The component is provided as a reference material, which may be inappropriate 42 | * for use without additional customization. 43 | *
44 | */ 45 | 46 | public class AuthSSLInitializationError extends Error { 47 | 48 | /** 49 | * Creates a new AuthSSLInitializationError. 50 | */ 51 | public AuthSSLInitializationError() { 52 | super(); 53 | } 54 | 55 | /** 56 | * Creates a new AuthSSLInitializationError with the specified message. 57 | * 58 | * @param message error message 59 | */ 60 | public AuthSSLInitializationError(String message) { 61 | super(message); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /http4e-Core/src/app/org/apache/commons/httpclient/contrib/ssl/HostConfigurationWithHostFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.httpclient.contrib.ssl; 2 | 3 | import org.apache.commons.httpclient.HostConfiguration; 4 | import org.apache.commons.httpclient.HttpURL; 5 | import org.apache.commons.httpclient.protocol.Protocol; 6 | 7 | /** 8 | * A kind of HostConfiguration that gets its Host from a factory. This is useful 9 | * for integrating a specialized Protocol or SocketFactory; for example, a 10 | * SecureSocketFactory that authenticates via SSL. Use 11 | * HttpClient.setHostConfiguration to install a HostConfigurationWithHostFactory 12 | * that contains the specialized HostFactory, Protocol or SocketFactory. 13 | *
14 | * An alternative is to use Protocol.registerProtocol to register a specialized
15 | * Protocol. But that has drawbacks: it makes it hard to integrate modules (e.g.
16 | * web applications in a servlet container) with different strategies, because
17 | * they share the specialized Protocol (Protocol.PROTOCOLS is static). And it
18 | * can't support different Protocols for different hosts or ports (since the
19 | * host and port aren't parameters to Protocol.getProtocol).
20 | *
21 | * @author John Kristian
22 | */
23 | class HostConfigurationWithHostFactory extends HostConfiguration
24 | {
25 | public HostConfigurationWithHostFactory(HttpHostFactory factory)
26 | {
27 | this.factory = factory;
28 | }
29 |
30 | private HostConfigurationWithHostFactory(HostConfigurationWithHostFactory that)
31 | {
32 | super(that);
33 | this.factory = that.factory;
34 | }
35 |
36 | private final HttpHostFactory factory;
37 |
38 | public Object clone()
39 | {
40 | return new HostConfigurationWithHostFactory(this);
41 | }
42 |
43 | private static final String DEFAULT_SCHEME = new String(HttpURL.DEFAULT_SCHEME);
44 |
45 | public void setHost(String host)
46 | {
47 | setHost(host, Protocol.getProtocol(DEFAULT_SCHEME).getDefaultPort());
48 | }
49 |
50 | public void setHost(final String host, int port)
51 | {
52 | setHost(host, port, DEFAULT_SCHEME);
53 | }
54 |
55 | public synchronized void setHost(String host, int port, String scheme)
56 | {
57 | setHost(factory.getHost(this, scheme, host, port));
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/apache/commons/httpclient/contrib/ssl/HttpHostFactory.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.httpclient.contrib.ssl;
2 |
3 | import org.apache.commons.httpclient.HostConfiguration;
4 | import org.apache.commons.httpclient.HttpHost;
5 | import org.apache.commons.httpclient.HttpsURL;
6 | import org.apache.commons.httpclient.protocol.Protocol;
7 | import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
8 |
9 | /** A source of HttpHosts. */
10 | public class HttpHostFactory
11 | {
12 | /** The default factory. */
13 | public static final HttpHostFactory DEFAULT = new HttpHostFactory(null, // httpProtocol
14 | new Protocol(new String(HttpsURL.DEFAULT_SCHEME),
15 | (ProtocolSocketFactory) new EasySSLProtocolSocketFactory(),
16 | HttpsURL.DEFAULT_PORT));
17 |
18 | public HttpHostFactory(Protocol httpProtocol, Protocol httpsProtocol)
19 | {
20 | this.httpProtocol = httpProtocol;
21 | this.httpsProtocol = httpsProtocol;
22 | }
23 |
24 | protected final Protocol httpProtocol;
25 |
26 | protected final Protocol httpsProtocol;
27 |
28 | /** Get a host for the given parameters. This method need not be thread-safe. */
29 | public HttpHost getHost(HostConfiguration old, String scheme, String host, int port)
30 | {
31 | return new HttpHost(host, port, getProtocol(old, scheme, host, port));
32 | }
33 |
34 | /**
35 | * Get a Protocol for the given parameters. The default implementation
36 | * selects a protocol based only on the scheme. Subclasses can do fancier
37 | * things, such as select SSL parameters based on the host or port. This
38 | * method must not return null.
39 | */
40 | protected Protocol getProtocol(HostConfiguration old, String scheme, String host, int port)
41 | {
42 | final Protocol oldProtocol = old.getProtocol();
43 | if (oldProtocol != null) {
44 | final String oldScheme = oldProtocol.getScheme();
45 | if (oldScheme == scheme || (oldScheme != null && oldScheme.equalsIgnoreCase(scheme))) {
46 | // The old protocol has the desired scheme.
47 | return oldProtocol; // Retain it.
48 | }
49 | }
50 | Protocol newProtocol = (scheme != null && scheme.toLowerCase().endsWith("s")) ? httpsProtocol
51 | : httpProtocol;
52 | if (newProtocol == null) {
53 | newProtocol = Protocol.getProtocol(scheme);
54 | }
55 | return newProtocol;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/eclipse/swt/snippets/Snippet163.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2000, 2004 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * IBM Corporation - initial API and implementation
10 | *******************************************************************************/
11 | package org.eclipse.swt.snippets;
12 |
13 | /*
14 | * Setting the font style, foreground and background colors of StyledText
15 | *
16 | * For a list of all SWT example snippets see
17 | * http://www.eclipse.org/swt/snippets/
18 | */
19 | import org.eclipse.swt.*;
20 | import org.eclipse.swt.custom.*;
21 | import org.eclipse.swt.layout.*;
22 | import org.eclipse.swt.widgets.*;
23 |
24 | public class Snippet163 {
25 |
26 | public static void main(String[] args) {
27 | Display display = new Display();
28 | Shell shell = new Shell(display);
29 | shell.setLayout(new FillLayout());
30 | StyledText text = new StyledText (shell, SWT.BORDER);
31 | text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ");
32 | // make 0123456789 appear bold
33 | StyleRange style1 = new StyleRange();
34 | style1.start = 0;
35 | style1.length = 10;
36 | style1.fontStyle = SWT.BOLD;
37 | text.setStyleRange(style1);
38 | // make ABCDEFGHIJKLM have a red font
39 | StyleRange style2 = new StyleRange();
40 | style2.start = 11;
41 | style2.length = 13;
42 | style2.foreground = display.getSystemColor(SWT.COLOR_RED);
43 | text.setStyleRange(style2);
44 | // make NOPQRSTUVWXYZ have a blue background
45 | StyleRange style3 = new StyleRange();
46 | style3.start = 25;
47 | style3.length = 13;
48 | style3.background = display.getSystemColor(SWT.COLOR_BLUE);
49 | text.setStyleRange(style3);
50 |
51 | shell.pack();
52 | shell.open();
53 | while (!shell.isDisposed()) {
54 | if (!display.readAndDispatch())
55 | display.sleep();
56 | }
57 | display.dispose();
58 | }
59 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/eclipse/swt/snippets/Snippet332.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2000, 2009 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * IBM Corporation - initial API and implementation
10 | *******************************************************************************/
11 | package org.eclipse.swt.snippets;
12 |
13 | /*
14 | * SWT StyledText snippet: using BidiSegmentEvent#segmentsChars to implement custom bidi segments
15 | *
16 | * For a list of all SWT example snippets see
17 | * http://www.eclipse.org/swt/snippets/
18 | *
19 | * @since 3.6
20 | */
21 | import org.eclipse.swt.*;
22 | import org.eclipse.swt.layout.*;
23 | import org.eclipse.swt.widgets.*;
24 | import org.eclipse.swt.custom.*;
25 | import org.eclipse.swt.graphics.*;
26 |
27 | public class Snippet332 {
28 |
29 | public static void main(String [] args) {
30 | final Display display = new Display();
31 | Shell shell = new Shell(display);
32 | FillLayout layout = new FillLayout();
33 | layout.marginHeight = layout.marginWidth = 10;
34 | shell.setLayout(layout);
35 | StyledText text = new StyledText(shell, SWT.MULTI | SWT.BORDER);
36 | final String segment = "Eclipse";
37 | String string = "Force RTL direction on this segment \""+segment+"\".";
38 | text.setText(string);
39 | int[] segments = {string.indexOf(segment), segment.length()};
40 | StyleRange[] ranges = {new StyleRange(0, 0, display.getSystemColor(SWT.COLOR_RED), null)};
41 | text.setStyleRanges(segments, ranges);
42 | text.setFont(new Font(display, "Tahoma", 16, 0));
43 | text.addBidiSegmentListener(new BidiSegmentListener() {
44 | public void lineGetSegments(BidiSegmentEvent event) {
45 | String string = event.lineText;
46 | int start = string.indexOf(segment);
47 | event.segments = new int []{start, start + segment.length()};
48 | // event.data = new char[] {'\u202e', '\u202C'};
49 | }
50 | });
51 | shell.setSize(500, 200);
52 | shell.open();
53 | while (!shell.isDisposed()) {
54 | if (!display.readAndDispatch()) display.sleep();
55 | }
56 | display.dispose();
57 | }
58 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/json/me/JSONException.java:
--------------------------------------------------------------------------------
1 | package org.json.me;
2 |
3 | /**
4 | * The JSONException is thrown by the JSON.org classes then things are amiss.
5 | * @author JSON.org
6 | * @version 2
7 | */
8 | public class JSONException extends Exception {
9 | private Throwable cause;
10 |
11 | /**
12 | * Constructs a JSONException with an explanatory message.
13 | * @param message Detail about the reason for the exception.
14 | */
15 | public JSONException(String message) {
16 | super(message);
17 | }
18 |
19 | public JSONException(Throwable t) {
20 | super(t.getMessage());
21 | this.cause = t;
22 | }
23 |
24 | public Throwable getCause() {
25 | return this.cause;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/json/me/JSONString.java:
--------------------------------------------------------------------------------
1 | package org.json.me;
2 | /**
3 | * The JSONString
interface allows a toJSONString()
4 | * method so that a class can change the behavior of
5 | * JSONObject.toString()
, JSONArray.toString()
,
6 | * and JSONWriter.value(
Object)
. The
7 | * toJSONString
method will be used instead of the default behavior
8 | * of using the Object's toString()
method and quoting the result.
9 | */
10 | public interface JSONString {
11 | /**
12 | * The toJSONString
method allows a class to produce its own JSON
13 | * serialization.
14 | *
15 | * @return A strictly syntactically correct JSON text.
16 | */
17 | public String toJSONString();
18 | }
19 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/json/me/SWTHelloWorld.java:
--------------------------------------------------------------------------------
1 | package org.json.me;
2 |
3 | import org.eclipse.swt.SWT;
4 | import org.eclipse.swt.widgets.Display;
5 | import org.eclipse.swt.widgets.Shell;
6 | import org.eclipse.swt.widgets.Text;
7 |
8 | public class SWTHelloWorld {
9 |
10 | public static void main( String[] args){
11 | Display display = new Display();
12 | Shell shell = new Shell(display);
13 |
14 | // Text helloWorldTest = new Text(shell, SWT.NONE);
15 | // helloWorldTest.setText("Hello World SWT");
16 | // helloWorldTest.pack();
17 |
18 | Ch5CompletionEditor ch5CompletionEditor = new Ch5CompletionEditor(shell);
19 |
20 |
21 | shell.pack();
22 | shell.open();
23 | while (!shell.isDisposed()) {
24 | if (!display.readAndDispatch())
25 | display.sleep();
26 | }
27 | display.dispose();
28 | }
29 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/json/me/SWTStyledTextExample.java:
--------------------------------------------------------------------------------
1 | package org.json.me;
2 |
3 |
4 | import org.eclipse.jface.text.source.SourceViewer;
5 | import org.eclipse.swt.SWT;
6 | import org.eclipse.swt.custom.StyledText;
7 | import org.eclipse.swt.layout.FillLayout;
8 | import org.eclipse.swt.widgets.Composite;
9 | import org.eclipse.swt.widgets.Display;
10 | import org.eclipse.swt.widgets.Shell;
11 | import org.roussev.http4e.editor.xml.XMLConfiguration;
12 | import org.roussev.http4e.httpclient.core.client.view.assist.DocumentUtils;
13 | import org.roussev.http4e.httpclient.core.misc.ColorManagerAdaptor;
14 | import org.roussev.http4e.httpclient.core.util.ResourceUtils;
15 |
16 | public class SWTStyledTextExample {
17 |
18 | private static StyledText buildEditorText( Composite parent){
19 | final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
20 |
21 | final XMLConfiguration sourceConf = new XMLConfiguration(new ColorManagerAdaptor(ResourceUtils.getResourceCache()));
22 | sourceViewer.configure(sourceConf);
23 | sourceViewer.setDocument(DocumentUtils.createDocument2());
24 |
25 | return sourceViewer.getTextWidget();
26 | }
27 |
28 |
29 | public static void main( String[] args){
30 |
31 | Shell shell = new Shell();
32 | shell.setLayout(new FillLayout());
33 | shell.setSize(200, 100);
34 | Display display = shell.getDisplay();
35 |
36 | // JsonTextEditor editor = new JsonTextEditor();
37 | // editor.gete
38 |
39 | StyledText styledText = buildEditorText(shell);
40 |
41 | shell.open();
42 |
43 | while (!shell.isDisposed()) {
44 | if (!display.readAndDispatch()) {
45 | display.sleep();
46 | }
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/json/me/StringWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2006 Sun Microsystems, Inc.
3 | */
4 |
5 | package org.json.me;
6 |
7 | import java.io.IOException;
8 | import java.io.Writer;
9 |
10 | /**
11 | * A simple StringBuffer-based implementation of StringWriter
12 | */
13 | public class StringWriter extends Writer {
14 |
15 | final private StringBuffer buf;
16 |
17 | public StringWriter() {
18 | super();
19 | buf = new StringBuffer();
20 | }
21 |
22 | public StringWriter(int initialSize) {
23 | super();
24 | buf = new StringBuffer(initialSize);
25 | }
26 |
27 | public void write(char[] cbuf, int off, int len) throws IOException {
28 | buf.append(cbuf, off, len);
29 | }
30 |
31 | public void write(String str) throws IOException {
32 | buf.append(str);
33 | }
34 |
35 | public void write(String str, int off, int len) throws IOException {
36 | buf.append(str.substring(off, len));
37 | }
38 |
39 | public void flush() throws IOException {
40 | }
41 |
42 | public void close() throws IOException {
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/json/me/test/SyntaxData.java:
--------------------------------------------------------------------------------
1 | package org.json.me.test;
2 |
3 | import java.util.Collection;
4 |
5 | /**
6 | * This class contains information for syntax coloring and styling for an
7 | * extension
8 | */
9 | public class SyntaxData {
10 |
11 | public String extension;
12 | public Collection keywords;
13 | public String punctuation;
14 | public String comment;
15 | public String multiLineCommentStart;
16 | public String multiLineCommentEnd;
17 |
18 |
19 | public SyntaxData( String extension) {
20 | this.extension = extension;
21 | }
22 |
23 |
24 | public String getExtension(){
25 | return extension;
26 | }
27 |
28 |
29 | public String getComment(){
30 | return comment;
31 | }
32 |
33 |
34 | public void setComment( String comment){
35 | this.comment = comment;
36 | }
37 |
38 |
39 | public Collection getKeywords(){
40 | return keywords;
41 | }
42 |
43 |
44 | public void setKeywords( Collection keywords){
45 | this.keywords = keywords;
46 | }
47 |
48 |
49 | public String getMultiLineCommentEnd(){
50 | return multiLineCommentEnd;
51 | }
52 |
53 |
54 | public void setMultiLineCommentEnd( String multiLineCommentEnd){
55 | this.multiLineCommentEnd = multiLineCommentEnd;
56 | }
57 |
58 |
59 | public String getMultiLineCommentStart(){
60 | return multiLineCommentStart;
61 | }
62 |
63 |
64 | public void setMultiLineCommentStart( String multiLineCommentStart){
65 | this.multiLineCommentStart = multiLineCommentStart;
66 | }
67 |
68 |
69 | public String getPunctuation(){
70 | return punctuation;
71 | }
72 |
73 |
74 | public void setPunctuation( String punctuation){
75 | this.punctuation = punctuation;
76 | }
77 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/json/me/test/SyntaxManager2.java:
--------------------------------------------------------------------------------
1 | package org.json.me.test;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collection;
5 | import java.util.Hashtable;
6 | import java.util.Map;
7 | import java.util.MissingResourceException;
8 | import java.util.ResourceBundle;
9 | import java.util.StringTokenizer;
10 |
11 |
12 | /**
13 | * This class manages the syntax coloring and styling data
14 | */
15 | class SyntaxManager2 {
16 | // Lazy cache of SyntaxData objects
17 | private static Map data = new Hashtable();
18 |
19 | /**
20 | * Gets the syntax data for an extension
21 | */
22 | public static synchronized SyntaxData getSyntaxData(String extension) {
23 | // Check in cache
24 | SyntaxData sd = (SyntaxData) data.get(extension);
25 | if (sd == null) {
26 | // Not in cache; load it and put in cache
27 | sd = loadSyntaxData(extension);
28 | if (sd != null) data.put(sd.getExtension(), sd);
29 | }
30 | return sd;
31 | }
32 |
33 | /**
34 | * Loads the syntax data for an extension
35 | *
36 | * @param extension the extension to load
37 | * @return SyntaxData
38 | */
39 | private static SyntaxData loadSyntaxData(String extension) {
40 | SyntaxData sd = null;
41 | try {
42 | ResourceBundle rb = ResourceBundle.getBundle("examples.ch11." + extension);
43 | sd = new SyntaxData(extension);
44 | sd.setComment(rb.getString("comment"));
45 | sd.setMultiLineCommentStart(rb.getString("multilinecommentstart"));
46 | sd.setMultiLineCommentEnd(rb.getString("multilinecommentend"));
47 |
48 | // Load the keywords
49 | Collection keywords = new ArrayList();
50 | for (StringTokenizer st = new StringTokenizer(rb.getString("keywords"), " "); st
51 | .hasMoreTokens();) {
52 | keywords.add(st.nextToken());
53 | }
54 | sd.setKeywords(keywords);
55 |
56 | // Load the punctuation
57 | sd.setPunctuation(rb.getString("punctuation"));
58 | } catch (MissingResourceException e) {
59 | // Ignore
60 | }
61 | return sd;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/json/me/test/Uutt.java:
--------------------------------------------------------------------------------
1 | package org.json.me.test;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.FileReader;
5 |
6 | public class Uutt {
7 |
8 | public static String readFileAsString( String filePath) throws java.io.IOException{
9 | StringBuffer fileData = new StringBuffer(1000);
10 | BufferedReader reader = new BufferedReader(new FileReader(filePath));
11 | char[] buf = new char[1024];
12 | int numRead = 0;
13 | while ((numRead = reader.read(buf)) != -1) {
14 | String readData = String.valueOf(buf, 0, numRead);
15 | fileData.append(readData);
16 | buf = new char[1024];
17 | }
18 | reader.close();
19 | return fileData.toString();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/crypt/CryptConstants.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.crypt;
2 |
3 | public interface CryptConstants {
4 |
5 | String UTF8 = "UTF8";
6 |
7 | // 8-bytes Salt
8 | byte[] SALT = {
9 | (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
10 | (byte)0x56, (byte)0x34, (byte)0xE3, (byte)0x03
11 | };
12 |
13 | int ITERATION_COUNT = 19;
14 |
15 | String SECRET_KEY_ALGORITHM = "PBEWithMD5AndDES";
16 |
17 | String HMAC_ALGORITHM = "HmacSHA1";
18 |
19 | String MESSAGE_DIGEST_ALGORITHM = "SHA1";
20 |
21 | String PUBLIC_KEY_ALGORITHM = "RSA"; //"DSA", "DH", "RSA"
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/crypt/Errors.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.crypt;
2 |
3 | public class Errors extends Exception {
4 |
5 | public final static int
6 | SUCCESS = 0,
7 | KEY_TABLE_READ = 1,
8 | TOKEN_READ = 2,
9 | EMAIL_EMPTY = 3,
10 | UNSUPPORTED_ENCODING = 4,
11 | MAJOR_MINOR_NOT_SUPPORTED = 5,
12 | EMAIL_DOESNOT_MATCH = 6,
13 | UNKNOWN = 100
14 | ;
15 |
16 | private int code = SUCCESS;
17 |
18 | public Errors(int code){
19 | this.code = code;
20 | }
21 |
22 | public Errors(int code, String msg){
23 | super(msg);
24 | this.code = code;
25 | }
26 |
27 | public Errors(int code, Throwable throwable){
28 | super(throwable);
29 | this.code = code;
30 | }
31 |
32 | public int getCode(){
33 | return code;
34 | }
35 |
36 | public void setCode( int code){
37 | this.code = code;
38 | }
39 |
40 |
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/crypt/MiscUtils.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.crypt;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 |
6 | public class MiscUtils {
7 |
8 | public static byte[] streamToBytes( InputStream in) throws IOException{
9 | byte[] bytes = new byte[in.available()];
10 | in.read(bytes);
11 | in.close();
12 | return bytes;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/crypt/depricated/Qwe.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.crypt.depricated;
2 |
3 |
4 | public class Qwe {
5 |
6 | public static void main( String[] args) throws Exception{
7 |
8 | String property = "java.io.tmpdir";
9 | String tempDir = System.getProperty(property);
10 |
11 | System.out.println(tempDir);
12 |
13 | // // Display display = new Display ();
14 | // // Shell shell = new Shell (display);
15 | // // StyledText text = new StyledText (shell, SWT.SINGLE | SWT.BORDER);
16 | // // text.setText ( "123-\u0067\u0035\u039e\u322F\u5193" );
17 | // // System.out.println ( "123-\u0067\u0035\u039e\u322F\u5193" );
18 | // // text.pack ();
19 | // // shell.pack ();
20 | // // shell.open ();
21 | // // while (!shell.isDisposed ()) {
22 | // // if (!display.readAndDispatch ()) display.sleep ();
23 | // // }
24 | // // display.dispose ();
25 | // FileInputStream fis = new FileInputStream("c:/utf.txt");
26 | // // byte[] data = new byte[fis.available()];
27 | // // fis.read(data);
28 | // // ByteArrayInputStream bys = new ByteArrayInputStream(data);
29 | // InputStreamReader inR = new InputStreamReader(fis, "UTF8");
30 | // // String line = "qqq=ee";
31 | // // String[] params = line.split("=");
32 | // // System.out.println(params);
33 | //
34 | // BufferedReader buf = new BufferedReader(inR);
35 | // String line;
36 | // StringBuilder respBuff = new StringBuilder();
37 | // while ((line = buf.readLine()) != null) {
38 | // respBuff.append(line);
39 | // respBuff.append("\r\n");
40 | // String[] params = line.split("\\:=");
41 | // System.out.println(params);
42 | // Properties p = null;
43 | // InputStream in = null;
44 | //// InputStreamReader inR = null;
45 | // p.load(in);
46 | // }
47 | // System.out.println(respBuff);
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/ColorManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml;
17 |
18 | import org.eclipse.swt.graphics.Color;
19 | import org.eclipse.swt.graphics.RGB;
20 |
21 | /**
22 | *
23 | * @author Atanas Roussev (http://nextinterfaces.com)
24 | */
25 | public interface ColorManager {
26 |
27 | void dispose();
28 |
29 | Color getColor(RGB rgb);
30 |
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/IXMLColorConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml;
17 |
18 | import org.eclipse.swt.graphics.RGB;
19 |
20 | /**
21 | *
22 | * @author Atanas Roussev (http://nextinterfaces.com)
23 | */
24 | public interface IXMLColorConstants {
25 |
26 | RGB XML_COMMENT = new RGB(128, 0, 0);
27 | RGB PROC_INSTR = new RGB(200, 20, 200);
28 | RGB DOCTYPE = new RGB(0, 150, 150);
29 | RGB STRING = new RGB(0, 128, 0);
30 | RGB DEFAULT = new RGB(0, 0, 0);
31 | RGB TAG = new RGB(0, 0, 128);
32 |
33 | // enhancements
34 | RGB ESCAPED_CHAR = new RGB(128, 128, 0);
35 | RGB CDATA = new RGB(0, 128, 128);
36 | RGB CDATA_TEXT = new RGB(255, 0, 0);
37 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/XMLWhitespaceDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml;
17 |
18 | import org.eclipse.jface.text.rules.IWhitespaceDetector;
19 |
20 | /**
21 | * @author Atanas Roussev (http://nextinterfaces.com)
22 | */
23 | public class XMLWhitespaceDetector implements IWhitespaceDetector {
24 |
25 | public boolean isWhitespace(char c) {
26 | return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/format/DefaultFormattingStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.format;
17 |
18 | import org.eclipse.jface.text.formatter.IFormattingStrategy;
19 |
20 | /**
21 | *
22 | * @author Phil Zoio
23 | */
24 | public class DefaultFormattingStrategy implements IFormattingStrategy {
25 |
26 | protected static final String lineSeparator = System.getProperty("line.separator");
27 |
28 |
29 | public DefaultFormattingStrategy() {
30 | super();
31 | }
32 |
33 |
34 | public void formatterStarts( String initialIndentation){
35 | }
36 |
37 |
38 | public String format( String content, boolean isLineStart, String indentation, int[] positions){
39 | return "";
40 | }
41 |
42 |
43 | public void formatterStops(){
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/format/DocTypeFormattingStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created on Oct 11, 2004
3 | */
4 | package org.roussev.http4e.editor.xml.format;
5 |
6 | /**
7 | *
8 | * @author Phil Zoio
9 | */
10 | public class DocTypeFormattingStrategy extends DefaultFormattingStrategy {
11 |
12 | public String format( String content, boolean isLineStart, String indentation, int[] positions){
13 | return lineSeparator + content;
14 | }
15 |
16 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/format/PIFormattingStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.format;
17 |
18 | /**
19 | *
20 | * @author Phil Zoio
21 | */
22 | public class PIFormattingStrategy extends DefaultFormattingStrategy {
23 |
24 | public String format( String content, boolean isLineStart, String indentation, int[] positions){
25 | return content;
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/format/TextFormattingStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.format;
17 |
18 | /**
19 | *
20 | * @author Phil Zoio
21 | */
22 | public class TextFormattingStrategy extends DefaultFormattingStrategy {
23 |
24 | private static final String lineSeparator = System.getProperty("line.separator");
25 |
26 |
27 | public TextFormattingStrategy() {
28 | super();
29 | }
30 |
31 |
32 | public String format( String content, boolean isLineStart, String indentation, int[] positions){
33 | if (indentation.length() == 0)
34 | return content;
35 | return lineSeparator + content.trim() + lineSeparator + indentation;
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/rules/EscapedCharRule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.rules;
17 |
18 | import org.eclipse.jface.text.rules.ICharacterScanner;
19 | import org.eclipse.jface.text.rules.IRule;
20 | import org.eclipse.jface.text.rules.IToken;
21 | import org.eclipse.jface.text.rules.Token;
22 |
23 | public class EscapedCharRule implements IRule {
24 |
25 | IToken fToken;
26 | StringBuilder buffer = new StringBuilder();
27 |
28 |
29 | public EscapedCharRule( IToken token) {
30 | super();
31 | this.fToken = token;
32 | }
33 |
34 |
35 | /*
36 | * @see IRule#evaluate(ICharacterScanner)
37 | */
38 | public IToken evaluate( ICharacterScanner scanner){
39 |
40 | buffer.setLength(0);
41 |
42 | int c = read(scanner);
43 | if (c == '&') {
44 |
45 | int i = 0;
46 | do {
47 | c = read(scanner);
48 | i++;
49 |
50 | if (c == '<' || c == ']') {
51 | for (int j = i - 1; j > 0; j--)
52 | scanner.unread();
53 | return Token.UNDEFINED;
54 | }
55 | } while (c != ';');
56 | return fToken;
57 | }
58 |
59 | scanner.unread();
60 | return Token.UNDEFINED;
61 | }
62 |
63 |
64 | private int read( ICharacterScanner scanner){
65 | int c = scanner.read();
66 | buffer.append((char) c);
67 | return c;
68 | }
69 |
70 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/rules/NonMatchingRule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.rules;
17 |
18 | import org.eclipse.jface.text.rules.ICharacterScanner;
19 | import org.eclipse.jface.text.rules.IPredicateRule;
20 | import org.eclipse.jface.text.rules.IToken;
21 | import org.eclipse.jface.text.rules.Token;
22 |
23 | /**
24 | *
25 | * @author Phil Zoio
26 | */
27 | public class NonMatchingRule implements IPredicateRule {
28 |
29 | public NonMatchingRule() {
30 | super();
31 | }
32 |
33 |
34 | public IToken getSuccessToken(){
35 | return Token.UNDEFINED;
36 | }
37 |
38 |
39 | public IToken evaluate( ICharacterScanner scanner, boolean resume){
40 | return Token.UNDEFINED;
41 | }
42 |
43 |
44 | public IToken evaluate( ICharacterScanner scanner){
45 | return Token.UNDEFINED;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/rules/StartTagRule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.rules;
17 |
18 | import org.eclipse.jface.text.rules.ICharacterScanner;
19 | import org.eclipse.jface.text.rules.IToken;
20 | import org.eclipse.jface.text.rules.MultiLineRule;
21 |
22 | /**
23 | *
24 | * @author Phil Zoio
25 | */
26 | public class StartTagRule extends MultiLineRule {
27 |
28 | public StartTagRule( IToken token) {
29 | this(token, false);
30 | }
31 |
32 |
33 | protected StartTagRule( IToken token, boolean endAsWell) {
34 | super("<", endAsWell ? "/>" : ">", token);
35 | }
36 |
37 |
38 | protected boolean sequenceDetected( ICharacterScanner scanner, char[] sequence, boolean eofAllowed){
39 | int c = scanner.read();
40 | if (sequence[0] == '<') {
41 | if (c == '?') {
42 | // processing instruction - abort
43 | scanner.unread();
44 | return false;
45 | }
46 | if (c == '!') {
47 | scanner.unread();
48 | // comment - abort
49 | return false;
50 | }
51 | } else if (sequence[0] == '>') {
52 | scanner.unread();
53 | }
54 | return super.sequenceDetected(scanner, sequence, eofAllowed);
55 | }
56 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/scanners/CDataScanner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.scanners;
17 |
18 | import org.eclipse.jface.text.TextAttribute;
19 | import org.eclipse.jface.text.rules.IRule;
20 | import org.eclipse.jface.text.rules.IToken;
21 | import org.eclipse.jface.text.rules.RuleBasedScanner;
22 | import org.eclipse.jface.text.rules.Token;
23 | import org.roussev.http4e.editor.xml.ColorManager;
24 | import org.roussev.http4e.editor.xml.IXMLColorConstants;
25 | import org.roussev.http4e.editor.xml.rules.CDataRule;
26 |
27 | /**
28 | * @author Atanas Roussev (http://nextinterfaces.com)
29 | */
30 | public class CDataScanner extends RuleBasedScanner {
31 |
32 | public IToken ESCAPED_CHAR;
33 | public IToken CDATA;
34 |
35 |
36 | public CDataScanner( ColorManager colorManager) {
37 |
38 | CDATA = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
39 |
40 | IRule[] rules = new IRule[2];
41 |
42 | // Add rule to pick up start of c section
43 | rules[0] = new CDataRule(CDATA, true);
44 | // Add a rule to pick up end of CDATA sections
45 | rules[1] = new CDataRule(CDATA, false);
46 |
47 | setRules(rules);
48 | }
49 |
50 |
51 | public IToken nextToken(){
52 | return super.nextToken();
53 | }
54 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/scanners/XMLScanner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.scanners;
17 |
18 | import org.eclipse.jface.text.TextAttribute;
19 | import org.eclipse.jface.text.rules.IRule;
20 | import org.eclipse.jface.text.rules.IToken;
21 | import org.eclipse.jface.text.rules.MultiLineRule;
22 | import org.eclipse.jface.text.rules.RuleBasedScanner;
23 | import org.eclipse.jface.text.rules.Token;
24 | import org.eclipse.jface.text.rules.WhitespaceRule;
25 | import org.roussev.http4e.editor.xml.ColorManager;
26 | import org.roussev.http4e.editor.xml.IXMLColorConstants;
27 | import org.roussev.http4e.editor.xml.XMLWhitespaceDetector;
28 |
29 |
30 | /**
31 | * @author Atanas Roussev (http://nextinterfaces.com)
32 | */
33 | public class XMLScanner extends RuleBasedScanner {
34 |
35 | public XMLScanner( ColorManager manager) {
36 | IToken procInstr = new Token(new TextAttribute(manager.getColor(IXMLColorConstants.PROC_INSTR)));
37 | IToken docType = new Token(new TextAttribute(manager.getColor(IXMLColorConstants.DOCTYPE)));
38 |
39 | IRule[] rules = new IRule[3];
40 | // Add rule for processing instructions and doctype
41 | rules[0] = new MultiLineRule("", "?>", procInstr);
42 | rules[1] = new MultiLineRule("", docType);
43 | // Add generic whitespace rule.
44 | rules[2] = new WhitespaceRule(new XMLWhitespaceDetector());
45 |
46 | setRules(rules);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/scanners/XMLTagScanner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.scanners;
17 |
18 | import org.eclipse.jface.text.TextAttribute;
19 | import org.eclipse.jface.text.rules.IRule;
20 | import org.eclipse.jface.text.rules.IToken;
21 | import org.eclipse.jface.text.rules.RuleBasedScanner;
22 | import org.eclipse.jface.text.rules.SingleLineRule;
23 | import org.eclipse.jface.text.rules.Token;
24 | import org.eclipse.jface.text.rules.WhitespaceRule;
25 | import org.roussev.http4e.editor.xml.ColorManager;
26 | import org.roussev.http4e.editor.xml.IXMLColorConstants;
27 | import org.roussev.http4e.editor.xml.XMLWhitespaceDetector;
28 |
29 |
30 | /**
31 | * @author Atanas Roussev (http://nextinterfaces.com)
32 | */
33 | public class XMLTagScanner extends RuleBasedScanner {
34 |
35 | public XMLTagScanner( ColorManager manager) {
36 | IToken string = new Token(new TextAttribute(manager.getColor(IXMLColorConstants.STRING)));
37 |
38 | IRule[] rules = new IRule[3];
39 |
40 | // Add rule for double quotes
41 | rules[0] = new SingleLineRule("\"", "\"", string, '\\');
42 | // Add a rule for single quotes
43 | rules[1] = new SingleLineRule("'", "'", string, '\\');
44 | // Add generic whitespace rule.
45 | rules[2] = new WhitespaceRule(new XMLWhitespaceDetector());
46 |
47 | setRules(rules);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/xmlattribs/XMLAttribute.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.xmlattribs;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | public class XMLAttribute {
22 |
23 | private String name;
24 | private String value;
25 |
26 |
27 | public XMLAttribute( String name) {
28 | super();
29 | this.name = name;
30 | }
31 |
32 |
33 | public XMLAttribute( String name, String value) {
34 | super();
35 | this.name = name;
36 | this.value = value;
37 | }
38 |
39 |
40 | public String getName(){
41 | return name;
42 | }
43 |
44 |
45 | public String getValue(){
46 | return value;
47 | }
48 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/editor/xml/xmlattribs/XMLValidationError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.editor.xml.xmlattribs;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | public class XMLValidationError {
22 |
23 | private String errorMessage;
24 | private int lineNumber;
25 | private int columnNumber;
26 |
27 |
28 | public String getErrorMessage(){
29 | return errorMessage;
30 | }
31 |
32 |
33 | public void setErrorMessage( String errorMessage){
34 | this.errorMessage = errorMessage;
35 | }
36 |
37 |
38 | public int getLineNumber(){
39 | return lineNumber;
40 | }
41 |
42 |
43 | public void setLineNumber( int lineNumber){
44 | this.lineNumber = lineNumber;
45 | }
46 |
47 |
48 | public int getColumnNumber(){
49 | return columnNumber;
50 | }
51 |
52 |
53 | public void setColumnNumber( int columnNumber){
54 | this.columnNumber = columnNumber;
55 | }
56 |
57 |
58 | public String toString(){
59 | StringBuilder buf = new StringBuilder();
60 | buf.append("Error on ").append(" line ").append(lineNumber).append(", column ").append(columnNumber).append(": ").append(errorMessage);
61 | return buf.toString();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/CoreContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core;
17 |
18 | import java.io.File;
19 | import java.util.HashMap;
20 | import java.util.Map;
21 |
22 | import org.eclipse.swt.widgets.Shell;
23 |
24 | /**
25 | * @author Atanas Roussev (http://nextinterfaces.com)
26 | */
27 | @SuppressWarnings("unchecked")
28 | public class CoreContext {
29 |
30 | public final static String PRODUCT_USER_DIR = System.getProperty("user.home") + File.separator + ".http4e";
31 |
32 | private static CoreContext context;
33 | static {
34 | context = new CoreContext();
35 | }
36 |
37 |
38 | public static CoreContext getContext(){
39 | return context;
40 | }
41 |
42 | private Map objectMap = new HashMap();
43 |
44 |
45 | public Object getObject( Object key){
46 | return objectMap.get(key);
47 | }
48 |
49 |
50 | public void putObject( Object key, Object value){
51 | objectMap.put(key, value);
52 | }
53 |
54 |
55 | public String toString(){
56 | return "CoreContext{" + "" + objectMap + "}";
57 | }
58 |
59 | public static Shell SHELL;
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/CoreMessages.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | public interface CoreMessages {
22 |
23 | String VERSION = "5.0.12";
24 | String PLUGIN_NAME = "HTTP4e Client";
25 | String PLUGIN_NAME_SHORT = "http4e";
26 | String PLUGIN_ABOUT = "Version: " + VERSION;
27 |
28 | String HEADER_DEFAULTS = ""; // "header=value";
29 | String PARAM_DEFAULTS = ""; // "parameter=value";
30 | String EMPTY_TITLE = "New Tab";
31 | String EMPTY_TITLE_NAME = "New Tab";
32 |
33 | String CONNECTION_REFUSED = "\n\tUnable to connect: Can't establish a connection to server \n\n\t";
34 | String CONNECTION_DROPPED = "\n\tIO error: The server dropped connection on us \n\n\t";
35 | String CONNECTION_IO_ERR = "\n\tIO error: Can't establish a connection to server \n\n\t";
36 | String CONNECTION_ILLEAGAL = "\n\tWrong argumens: HTTP4e can't establish a connection to server \n\n\t";
37 | String CONNECTION_UNKNOWN = "\n\tHTTP4e can't establish a connection to server \n\n\t";
38 | String ABORTED = "";
39 |
40 | String LICENSE_TITLE = "HTTP4e License";
41 | }
42 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/CoreObjects.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | public interface CoreObjects {
22 |
23 | String RESOURCE_CACHE = "resource.cache";
24 | String ROOT_PATH_CORE = "root.core";
25 | String ROOT_PATH_UI = "root.ui";
26 |
27 | String HTTP_HEADERS = "http.headers";
28 | String HTTP_HEADER_VALUES = "http.header.values";
29 | String HEADER_TYPE_TRACKER = "header.type.tracker";
30 | String PARAM_TYPE_TRACKER = "param.type.tracker";
31 | String IS_STANDALONE = "is.standalone";
32 | String AUTH_ITEM = "auth.bean";
33 | String PROXY_ITEM = "proxy.bean";
34 | String PARAMETERIZE_ARGS = "parameterize.args";
35 | String RESPONSE_VIEW_SIZE = "resp.size";
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/ExceptionHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core;
17 |
18 | /**
19 | * Central repository handling all exception types.
20 | *
21 | * @author Atanas Roussev (http://nextinterfaces.com)
22 | */
23 | public class ExceptionHandler {
24 |
25 | private final static boolean WARN_ENABLED = false;
26 |
27 |
28 | public static void handle( Throwable e){
29 | e.printStackTrace();
30 | if (e.getCause() != null) {
31 | handle(e.getCause());
32 | }
33 | }
34 |
35 |
36 | public static void print( String msg){
37 | System.out.println(">>>>" + msg);
38 | }
39 |
40 |
41 | public static void warn( String msg){
42 | if (WARN_ENABLED) {
43 | System.err.println(msg);
44 | }
45 | }
46 |
47 |
48 | public static void warn( Exception e){
49 | if (WARN_ENABLED) {
50 | System.err.println(e);
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/misc/ApacheHttpListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.misc;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | public interface ApacheHttpListener {
22 |
23 | void write( byte[] data);
24 |
25 | void close();
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/misc/ApacheOutputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.misc;
17 |
18 | import java.io.FilterOutputStream;
19 | import java.io.IOException;
20 | import java.io.OutputStream;
21 |
22 | /**
23 | * Logs all data written to the wire LOG.
24 | *
25 | * @author Oleg Kalnichevski
26 | *
27 | * @since 2.0beta1
28 | */
29 | public class ApacheOutputStream extends FilterOutputStream {
30 |
31 | /** Original input stream. */
32 | private OutputStream out;
33 |
34 | private ApacheHttpListener apacheHttpListener;
35 |
36 | /**
37 | * Create an instance that wraps the specified output stream.
38 | * @param out The output stream.
39 | * @param wire The Wire log to use.
40 | */
41 | public ApacheOutputStream(ApacheHttpListener apacheHttpListener, OutputStream out/*, Wire wire*/) {
42 | super(out);
43 | this.out = out;
44 | this.apacheHttpListener = apacheHttpListener;
45 | }
46 |
47 | /**
48 | *
49 | * @see java.io.OutputStream#write(byte[], int, int)
50 | */
51 | public void write(byte[] b, int off, int len) throws IOException {
52 | this.out.write(b, off, len);
53 | apacheHttpListener.write(b);
54 | }
55 |
56 | /**
57 | *
58 | * @see java.io.OutputStream#write(byte[])
59 | */
60 | public void write(byte[] b) throws IOException {
61 | this.out.write(b);
62 | apacheHttpListener.write(b);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/misc/JobListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.misc;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | public interface JobListener {
22 |
23 | /**
24 | * Starts buz operation, result is passed into update() method.
25 | */
26 | Object execute();
27 |
28 | /**
29 | * A callback update with result after job execution.
30 | */
31 | void update( Object value);
32 |
33 | boolean isDisposed();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/misc/JobRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.misc;
17 |
18 | import org.eclipse.swt.widgets.Composite;
19 | import org.eclipse.swt.widgets.Display;
20 |
21 | /**
22 | * @author Atanas Roussev (http://nextinterfaces.com)
23 | */
24 | public class JobRunner implements Runnable {
25 |
26 | private boolean done = false;
27 | private JobListener listener;
28 | private Composite composite;
29 |
30 | public JobRunner( Composite composite, JobListener listener) {
31 | this.listener = listener;
32 | this.composite = composite;
33 | }
34 |
35 | public void run(){
36 | // main swt thread
37 | final Display display = Display.getDefault();
38 |
39 | // start separate thread
40 | Thread separateThread = new Thread(new Runnable() {
41 | public void run(){
42 |
43 | if (display.isDisposed()) return;
44 | final Object execObj = listener.execute();
45 |
46 | if (display.isDisposed()) return;
47 | display.syncExec(new Runnable() {
48 | public void run(){
49 | // sync back to main swt thread
50 | if (listener.isDisposed())
51 | return;
52 | listener.update(execObj);
53 | }
54 | });
55 | done = true;
56 |
57 | if (display.isDisposed()) return;
58 | display.wake();
59 | }
60 | });
61 | separateThread.start();
62 |
63 | while (!done && !composite.isDisposed()) {
64 | if (!display.readAndDispatch())
65 | display.sleep();
66 | }
67 | }
68 |
69 | public boolean isFinished(){
70 | return done;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/model/Model.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.model;
17 |
18 | import java.io.Serializable;
19 |
20 | /**
21 | * @author Atanas Roussev (http://nextinterfaces.com)
22 | */
23 | public interface Model {
24 |
25 | void addListener( ModelListener listener);
26 |
27 | void removeListener( ModelListener listener);
28 |
29 | void fireExecute( ModelEvent e);
30 |
31 | public Serializable getSerializable();
32 |
33 | public void load( Serializable serializable);
34 | }
35 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/model/ModelListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.model;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | public interface ModelListener {
22 |
23 | public void executed( ModelEvent e);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/Animator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view;
17 |
18 | import org.eclipse.swt.graphics.Image;
19 | import org.eclipse.swt.graphics.ImageLoader;
20 | import org.eclipse.swt.widgets.Control;
21 | import org.roussev.http4e.httpclient.core.CoreConstants;
22 | import org.roussev.http4e.httpclient.core.CoreImages;
23 | import org.roussev.http4e.httpclient.core.misc.CoreException;
24 | import org.roussev.http4e.httpclient.core.util.ResourceUtils;
25 |
26 | /**
27 | * @author Atanas Roussev (http://nextinterfaces.com)
28 | */
29 | class Animator {
30 |
31 | private AnimatedGIFRunner gifRunner;
32 | private Control parent;
33 | private Image backgroundImage;
34 |
35 | Animator( Control parent, Image backgroundImage) {
36 | this.parent = parent;
37 | this.backgroundImage = backgroundImage;
38 | }
39 |
40 | void start(){
41 | if(gifRunner != null) gifRunner.stop();
42 | try {
43 | ImageLoader imageLoader = new ImageLoader();
44 | imageLoader.load( ResourceUtils.getBundleResourceStream(CoreConstants.PLUGIN_CORE, CoreImages.LOADING_ON));
45 | gifRunner = new AnimatedGIFRunner(parent, imageLoader, backgroundImage);
46 | } catch (Exception e) {
47 | throw CoreException.getInstance(CoreException.GENERAL, e);
48 | }
49 | final Thread animeThread = new Thread(gifRunner);
50 | animeThread.setDaemon(true);
51 | animeThread.start();
52 | }
53 |
54 | void stop(){
55 | if(gifRunner != null) gifRunner.stop();
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/ExecuteCommand.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.httpclient.core.client.view;
2 |
3 |
4 | public interface ExecuteCommand {
5 |
6 | void execute();
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/ExecuteKeyListener.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.httpclient.core.client.view;
2 |
3 | import org.eclipse.swt.events.KeyEvent;
4 | import org.eclipse.swt.events.KeyListener;
5 |
6 | public class ExecuteKeyListener implements KeyListener {
7 |
8 | private static final int SHIFT = 1 << 17;
9 |
10 | private static final int CTRL = 1 << 18;
11 |
12 | private ExecuteCommand cmd;
13 |
14 |
15 | public ExecuteKeyListener( ExecuteCommand cmd) {
16 | this.cmd = cmd;
17 | }
18 |
19 | public void keyPressed( KeyEvent e){
20 | // pass through
21 | }
22 |
23 | public void keyReleased( KeyEvent e){
24 | // String string = "";// e.type == SWT.KeyDown ? "DOWN:" : "UP :";
25 | // string += " stateMask=0x" + Integer.toHexString(e.stateMask) +
26 | // Snippet25.stateMask(e.stateMask) + ",";
27 | // string += " keyCode=0x" + Integer.toHexString(e.keyCode) + " " +
28 | // Snippet25.keyCode(e.keyCode) + ",";
29 | // string += " character=0x" + Integer.toHexString(e.character) + " " +
30 | // Snippet25.character(e.character);
31 | // if (e.keyLocation != 0) {
32 | // string += " location=";
33 | // if (e.keyLocation == SWT.LEFT)
34 | // string += "LEFT";
35 | // if (e.keyLocation == SWT.RIGHT)
36 | // string += "RIGHT";
37 | // if (e.keyLocation == SWT.KEYPAD)
38 | // string += "KEYPAD";
39 | //
40 | // }
41 |
42 | if ((e.stateMask & CTRL) != 0 && (e.stateMask & SHIFT) != 0 && e.keyCode == 'r') {
43 | // System.out.println(string);
44 | // model.fireExecute(new ModelEvent(ModelEvent.PARAMS_FOCUS_LOST,
45 | // model));
46 | // model.fireExecute(new ModelEvent(ModelEvent.REQUEST_START, model));
47 | cmd.execute();
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/IControlView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view;
17 |
18 | import org.eclipse.swt.widgets.Control;
19 |
20 | /**
21 | * @author Atanas Roussev (http://nextinterfaces.com)
22 | */
23 | interface IControlView {
24 |
25 | Control getControl();
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/ItemState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | class ItemState {
22 |
23 | public final static int POST_NO_UPDATE = 0;
24 | public final static int POST_ENABLED = 1;
25 | public final static int POST_DISABLED = 2;
26 |
27 | public final static int HTTP_STARTED = 3;
28 | public final static int HTTP_STOPPED = 4;
29 | public final static int HTTP_ABORTED = 5;
30 |
31 | private int state = POST_NO_UPDATE;
32 | private boolean xwwwEnabled = true;
33 |
34 | public int getState(){
35 | return state;
36 | }
37 |
38 | public void setState( int state){
39 | this.state = state;
40 | }
41 |
42 | public boolean isXwwwTypeEnabled(){
43 | return xwwwEnabled;
44 | }
45 |
46 | public void setXwwwTypeEnabled( boolean xwwwEnabled){
47 | this.xwwwEnabled = xwwwEnabled;
48 | }
49 |
50 | public String toString(){
51 | return "ItemState{state=" + getState() + ",xwwwEnabled=" + isXwwwTypeEnabled() + "}";
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/ParamTableView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view;
17 |
18 | import org.eclipse.swt.widgets.Composite;
19 | import org.eclipse.swt.widgets.Control;
20 | import org.roussev.http4e.httpclient.core.client.model.ItemModel;
21 |
22 |
23 | /**
24 | * @author Atanas Roussev (http://nextinterfaces.com)
25 | */
26 | class ParamTableView implements IControlView {
27 |
28 | Control control;
29 |
30 | ParamTableView( final ItemModel model, Composite parent) {
31 | control = new ParamTable().createContents(parent);
32 | }
33 |
34 | public Control getControl(){
35 | return control;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/SWTHelloWorld.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.httpclient.core.client.view;
2 |
3 | import org.eclipse.jface.text.source.SourceViewer;
4 | import org.eclipse.swt.SWT;
5 | import org.eclipse.swt.custom.StyledText;
6 | import org.eclipse.swt.layout.FillLayout;
7 | import org.eclipse.swt.widgets.Composite;
8 | import org.eclipse.swt.widgets.Display;
9 | import org.eclipse.swt.widgets.Shell;
10 | import org.roussev.http4e.editor.xml.XMLConfiguration;
11 | import org.roussev.http4e.httpclient.core.client.view.assist.DocumentUtils;
12 | import org.roussev.http4e.httpclient.core.misc.ColorManagerAdaptor;
13 | import org.roussev.http4e.httpclient.core.util.ResourceUtils;
14 |
15 | public class SWTHelloWorld {
16 |
17 | private static StyledText buildEditorText( Composite parent){
18 | final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
19 |
20 | final XMLConfiguration sourceConf = new XMLConfiguration(new ColorManagerAdaptor(ResourceUtils.getResourceCache()));
21 | sourceViewer.configure(sourceConf);
22 | sourceViewer.setDocument(DocumentUtils.createDocument2());
23 |
24 | return sourceViewer.getTextWidget();
25 | }
26 |
27 |
28 | public static void main( String[] args){
29 |
30 | Shell shell = new Shell();
31 | shell.setLayout(new FillLayout());
32 | shell.setSize(200, 100);
33 | Display display = shell.getDisplay();
34 |
35 | // JsonTextEditor editor = new JsonTextEditor();
36 | // editor.gete
37 |
38 | StyledText styledText = buildEditorText(shell);
39 |
40 | shell.open();
41 |
42 | while (!shell.isDisposed()) {
43 | if (!display.readAndDispatch()) {
44 | display.sleep();
45 | }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/assist/AssistConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view.assist;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | public interface AssistConstants {
22 |
23 | char EQUAL = '=';
24 | char SHARP = '#';
25 |
26 | String S_EQUAL = String.valueOf(EQUAL);
27 | String S_SHARP = String.valueOf(SHARP);
28 |
29 | String BRACKETS_COMPLETION = "=";
30 |
31 | String CONTENT_TYPE_MULTIPART = "multipart/form-data";
32 | String CONTENT_TYPE_X_WWW_FORM = "application/x-www-form-urlencoded";
33 | String HEADER_CONTENT_TYPE = "content-type";
34 | String HEADER_ACCEPT_CHARSET = "accept-charset";
35 | String HEADER_ACCEPT_LANGUAGE = "accept-language";
36 | String HEADER_DATE = "date";
37 | String HEADER_IF_MOD_SINCE = "if-modified-since";
38 | String HEADER_RETRY_AFTER = "Retry-After";
39 | String HEADER_LAST_MODIFIED = "Last-Modified";
40 | String HEADER_IF_UNMOD_SINCE = "If-Unmodified-Since";
41 | String HEADER_EXPIRES = "Expires";
42 |
43 |
44 | char LINE_DELIM_NL = '\n'; //10
45 | char LINE_DELIM_CR = '\r'; //13
46 | // String CRLF = System.getProperty("line.separator");
47 |
48 | String S_NL = String.valueOf(LINE_DELIM_NL);
49 | String PARAM_LINE_DELIM = "\r\n&";
50 | String PARAM_DELIM_EQ = "=";
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/assist/HAssistInfoMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view.assist;
17 |
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 | import java.util.Properties;
21 |
22 | import org.roussev.http4e.httpclient.core.CoreConstants;
23 | import org.roussev.http4e.httpclient.core.ExceptionHandler;
24 | import org.roussev.http4e.httpclient.core.util.ResourceUtils;
25 |
26 | /**
27 | * @author Atanas Roussev (http://nextinterfaces.com)
28 | */
29 | public class HAssistInfoMap {
30 |
31 | private Properties data;
32 |
33 | public HAssistInfoMap(String file){
34 | data = new Properties();
35 | try {
36 | InputStream in = ResourceUtils.getBundleResourceStream2(CoreConstants.PLUGIN_CORE, file);
37 | if(in != null) data.load(in);
38 | } catch (IOException ignore) {
39 | ExceptionHandler.warn(ignore);
40 | }
41 | }
42 |
43 | public String getInfo(String key){
44 | String val = data.getProperty(key);
45 | return val;
46 | }
47 |
48 | public String toString(){
49 | return "HAssistInfoMap:" + data;
50 | }
51 |
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/assist/HCommentScanner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view.assist;
17 |
18 | import org.eclipse.jface.text.rules.IRule;
19 | import org.eclipse.jface.text.rules.RuleBasedScanner;
20 |
21 | /**
22 | * @author Atanas Roussev (http://nextinterfaces.com)
23 | */
24 | public class HCommentScanner extends RuleBasedScanner {
25 |
26 | public HCommentScanner() {
27 | // IToken comment = new Token(HPartitionScanner.COMMENT);
28 | setRules(new IRule[] {
29 | // new SingleLineRule("#", null, comment, '\\', true, true),
30 | // new WhitespaceRule(new WhitespaceDetector())
31 | });
32 | }
33 | }
34 |
35 |
36 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/assist/HPartitionScanner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view.assist;
17 |
18 | import org.eclipse.jface.text.rules.IPredicateRule;
19 | import org.eclipse.jface.text.rules.IToken;
20 | import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
21 | import org.eclipse.jface.text.rules.SingleLineRule;
22 | import org.eclipse.jface.text.rules.Token;
23 |
24 | /**
25 | * @author Atanas Roussev (http://nextinterfaces.com)
26 | */
27 | public class HPartitionScanner extends RuleBasedPartitionScanner {
28 |
29 | public final static String PROPERTIES_PARTITIONING = "___pf_partitioning";
30 | public final static String COMMENT = "__pf_comment";
31 | public final static String PROPERTY_VALUE = "__pf_property_value";
32 | // public final static String PROPERTY_KEY = "__pf_property_key";
33 |
34 | public final static String[] PARTITIONS = new String[] {
35 | COMMENT, PROPERTY_VALUE, /*PROPERTY_KEY*/
36 | };
37 |
38 |
39 | public HPartitionScanner() {
40 | // IToken key= new Token(IDocument.DEFAULT_CONTENT_TYPE);
41 | IToken comment = new Token(COMMENT);
42 | IToken propertyValue = new Token(PROPERTY_VALUE);
43 |
44 | setPredicateRules(new IPredicateRule[] {
45 | new SingleLineRule(AssistConstants.PARAM_DELIM_EQ, null, propertyValue, '\\', true, true),
46 | new SingleLineRule("#", null, comment, (char) 0, true, true), });
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/assist/HValueScanner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view.assist;
17 |
18 | import org.eclipse.jface.text.rules.IRule;
19 | import org.eclipse.jface.text.rules.RuleBasedScanner;
20 |
21 | /**
22 | * @author Atanas Roussev (http://nextinterfaces.com)
23 | */
24 | public class HValueScanner extends RuleBasedScanner {
25 |
26 | public HValueScanner() {
27 | // IToken string = new Token(new TextAttribute(ResourceUtils.getColor(Styles.PROC_INSTR)));
28 |
29 | setRules(new IRule[] {
30 | // new SingleLineRule("\"", "\"", string, '\\'),
31 | // new SingleLineRule("'", "'", string, '\\'),
32 | // new SingleLineRule("<", "/>", string, '\\'),
33 | // new WhitespaceRule(new WhitespaceDetector())
34 | });
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/assist/ModelTrackerListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view.assist;
17 |
18 | /**
19 | * @author Atanas Roussev (http://nextinterfaces.com)
20 | */
21 | public interface ModelTrackerListener {
22 |
23 | void fireExecute(String key, String value);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/assist/MyAnnotationHover.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view.assist;
17 |
18 | import org.eclipse.jface.text.BadLocationException;
19 | import org.eclipse.jface.text.IDocument;
20 | import org.eclipse.jface.text.IRegion;
21 | import org.eclipse.jface.text.source.IAnnotationHover;
22 | import org.eclipse.jface.text.source.ISourceViewer;
23 |
24 | /**
25 | * @author Atanas Roussev (http://nextinterfaces.com)
26 | */
27 | public class MyAnnotationHover implements IAnnotationHover {
28 |
29 | public String getHoverInfo( ISourceViewer sourceViewer, int lineNumber){
30 | IDocument document = sourceViewer.getDocument();
31 | try {
32 | IRegion info = document.getLineInformation(lineNumber);
33 | return document.get(info.getOffset(), info.getLength());
34 | } catch (BadLocationException x) {
35 | }
36 | return null;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/client/view/assist/WhitespaceDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.client.view.assist;
17 |
18 | import org.eclipse.jface.text.rules.IWhitespaceDetector;
19 |
20 | /**
21 | * @author Atanas Roussev (http://nextinterfaces.com)
22 | */
23 | public class WhitespaceDetector implements IWhitespaceDetector {
24 |
25 | public boolean isWhitespace(char c) {
26 | return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
27 | }
28 | // public boolean isWhitespace( char c){
29 | // return Character.isWhitespace(c);
30 | // }
31 | }
32 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/misc/ColorManagerAdaptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.misc;
17 |
18 | import org.eclipse.swt.graphics.Color;
19 | import org.eclipse.swt.graphics.RGB;
20 | import org.roussev.http4e.editor.xml.ColorManager;
21 |
22 |
23 | /**
24 | * @author Atanas Roussev (http://nextinterfaces.com)
25 | */
26 | public class ColorManagerAdaptor implements ColorManager {
27 |
28 | private ResourceCache cache;
29 |
30 | public ColorManagerAdaptor(ResourceCache cache){
31 | this.cache = cache;
32 | }
33 |
34 | public void dispose(){
35 | cache.disposeColors();
36 | }
37 |
38 | public Color getColor( RGB rgb){
39 | return cache.getColor(rgb);
40 | }
41 | }
42 |
43 |
44 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/misc/Scripts.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.misc;
17 |
18 | /**
19 | * This interface contains the JavaScript functions used across http4E.
20 | *
21 | * @author Atanas Roussev (http://nextinterfaces.com)
22 | */
23 | public interface Scripts {
24 |
25 | String POPUP_WINDOW = "function popup_window(url, width, height, options){ " +
26 | "var w = (width) ? width : 400;" +
27 | "var h = (height) ? height : 400;" +
28 | "var t = (screen.height) ? (screen.height - h) / 2 : 0;" +
29 | "var l = (screen.width) ? (screen.width - w) / 2 : 0;" +
30 | "var opt = (options) ? options : 'toolbar = 1, location = 1, directories = 1, status = 1, menubar = 1, scrollbars = 1, copyhistory = no, resizable = 1';" +
31 | "var popped = window.open(url, 'popupwindow', 'top = '+t+', left = '+l+', width = '+w+', height = '+h+',' + opt);" +
32 | "popped.focus();" +
33 | "};";
34 |
35 | String HEADER = "
";
36 | String FOOTER = "
";
37 |
38 |
39 | }
40 |
41 |
42 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/util/JsonUtil.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.httpclient.core.util;
2 |
3 | public class JsonUtil {
4 |
5 | public static String hexToChar( String i, String j, String k, String l){
6 | return Character.toString((char) Integer.parseInt("" + i + j + k + l, 16));
7 | }
8 |
9 |
10 | public static String render( String value, boolean hubav, String indent){
11 | final StringBuilder sb = new StringBuilder();
12 | if (hubav) {
13 | sb.append(indent);
14 | }
15 |
16 | sb.append("\"");
17 | int len = value.length();
18 | for (int i = 0; i < len; i++) {
19 | final char lChar = value.charAt(i);
20 | if (lChar == '\n') {
21 | sb.append("\\n");
22 | } else if (lChar == '\r') {
23 | sb.append("\\r");
24 | } else if (lChar == '\f') {
25 | sb.append("\\f");
26 | } else if (lChar == '\t') {
27 | sb.append("\\t");
28 | } else if (lChar == '\b') {
29 | sb.append("\\b");
30 | // else if(lChar == '/') lBuf.append("\\/");
31 | } else if (lChar == '\"') {
32 | sb.append("\\\"");
33 | } else if (lChar == '\\') {
34 | sb.append("\\\\");
35 | } else {
36 | sb.append(lChar);
37 | }
38 | }
39 |
40 | return sb.append("\"").toString();
41 | }
42 |
43 | public static void main( String[] args){
44 | System.out.println(render(
45 | "{\"JSON\":\"Hello, World!\"}"//"[50,0,0,49,[\"hhhh\"],0,0,1,288,]"
46 | , false, " "));
47 |
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/util/ParseBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.util;
17 |
18 | import java.util.Collection;
19 | import java.util.HashSet;
20 | import java.util.Set;
21 |
22 | /**
23 | * @author Atanas Roussev (http://nextinterfaces.com)
24 | */
25 | class ParseBean {
26 |
27 | public String key;
28 | public Set values = new HashSet();
29 |
30 | public ParseBean( String key) {
31 | this.key = key;
32 | }
33 |
34 | public String getKey(){
35 | return key;
36 | }
37 |
38 | public void addValue( String val){
39 | this.values.add(val);
40 | }
41 |
42 | public Collection getValues(){
43 | return values;
44 | }
45 |
46 | public String toString(){
47 | return "Param{" +
48 | "key=" + key +
49 | ",values=" + values +
50 | "}";
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/util/ResponseReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.util;
17 |
18 | import org.apache.commons.httpclient.HttpMethod;
19 |
20 | /**
21 | * @author Atanas Roussev (http://nextinterfaces.com)
22 | */
23 | public interface ResponseReader {
24 |
25 | void read(HttpMethod httpMethod);
26 |
27 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/httpclient/core/util/StringPrintWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Eclipse HttpClient (http4e) http://nextinterfaces.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.roussev.http4e.httpclient.core.util;
17 |
18 | import java.io.PrintWriter;
19 | import java.io.StringWriter;
20 |
21 | /**
22 | * A PrintWriter that maintains a String as its backing store.
23 | *
24 | * Usage: StringPrintWriter out = new StringPrintWriter();
25 | * printTo(out); System.out.println( out.getString() );
26 | */
27 | class StringPrintWriter extends PrintWriter {
28 |
29 | public StringPrintWriter() {
30 | super(new StringWriter());
31 | }
32 |
33 |
34 | public StringPrintWriter( int initialSize) {
35 | super(new StringWriter(initialSize));
36 | }
37 |
38 |
39 | /**
40 | * <p>Since toString() returns information *about* this object, we want a
41 | * separate method to extract just the contents of the internal buffer as a
42 | * String.
43 | *
44 | *
45 | * @return the contents of the internal string buffer
46 | */
47 | public String getString(){
48 | flush();
49 | return ((StringWriter) out).toString();
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/jmeter/Constants.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.jmeter;
2 |
3 | public class Constants {
4 |
5 | public final static String[] HEADERS = { "Accept",
6 | "Accept-Charset",
7 | "Accept-Encoding",
8 | "Accept-Language",
9 | "Accept-Ranges",
10 | "Age",
11 | "Allow",
12 | "Authorization",
13 | "Cache-Control",
14 | "Connection",
15 | "Content-Encoding",
16 | "Content-Language",
17 | "Content-Length",
18 | "Content-Location",
19 | "Content-MD5",
20 | "Content-Range",
21 | "Content-Type",
22 | "Cookie",
23 | "Date",
24 | "ETag",
25 | "Expect",
26 | "Expires",
27 | "From",
28 | "Host",
29 | "If-Match",
30 | "If-Modified-Since",
31 | "If-None-Match",
32 | "If-Range",
33 | "If-Unmodified-Since",
34 | "Keep-Alive",
35 | "Last-Modified",
36 | "Location",
37 | "Max-Forwards",
38 | "Pragma",
39 | "Proxy-Authenticate",
40 | "Proxy-Authorization",
41 | "Range",
42 | "Referer",
43 | "Retry-After",
44 | "Server",
45 | "TE",
46 | "Trailer",
47 | "Transfer-Encoding",
48 | "Upgrade",
49 | "User-Agent",
50 | "Vary",
51 | "Via",
52 | "Warning",
53 | "WWW-Authenticate" };
54 | public final static String[] METHODS = {
55 | "POST",
56 | "GET",
57 | "PUT",
58 | "HEAD",
59 | "DELETE",
60 | "TRACE",
61 | "OPTIONS" };
62 | }
63 |
--------------------------------------------------------------------------------
/http4e-Core/src/app/org/roussev/http4e/jmeter/ExportTemplateTransformer.java:
--------------------------------------------------------------------------------
1 | package org.roussev.http4e.jmeter;
2 |
3 | import java.io.StringWriter;
4 | import java.io.Writer;
5 | import java.util.Properties;
6 |
7 | import org.apache.velocity.Template;
8 | import org.apache.velocity.VelocityContext;
9 | import org.apache.velocity.app.Velocity;
10 | import org.apache.velocity.exception.ParseErrorException;
11 | import org.apache.velocity.exception.ResourceNotFoundException;
12 | import org.roussev.http4e.httpclient.core.ExceptionHandler;
13 | import org.roussev.http4e.httpclient.core.util.HttpBean;
14 |
15 | public class ExportTemplateTransformer {
16 |
17 | private String templateFile;
18 | private HttpBean httpBean;
19 |
20 |
21 | public ExportTemplateTransformer( String templateFile, HttpBean httpBean) {
22 | this.templateFile = templateFile;
23 | this.httpBean = httpBean;
24 | }
25 |
26 | public void doWrite( Writer writer){
27 | try {
28 |
29 | Properties p = new Properties();
30 |
31 | // p.setProperty("resource.loader", "file");
32 | //// p.setProperty("file.resource.loader.path", "./src");
33 | // p.setProperty("file.resource.loader.class",
34 | // "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
35 |
36 | p.setProperty("resource.loader", "class");
37 | p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
38 |
39 | Velocity.init(p);
40 |
41 | VelocityContext context = new VelocityContext();
42 | context.put("httpBean", httpBean);
43 |
44 | Template template = null;
45 |
46 | try {
47 | template = Velocity.getTemplate(templateFile);
48 | } catch (ResourceNotFoundException e) {
49 | ExceptionHandler.handle(e);
50 | } catch (ParseErrorException e) {
51 | ExceptionHandler.handle(e);
52 | }
53 |
54 | if (template != null) {
55 | template.merge(context, writer);
56 | }
57 | /*
58 | * flush and cleanup
59 | */
60 |
61 | writer.flush();
62 | writer.close();
63 | } catch (Exception e) {
64 | ExceptionHandler.handle(e);
65 | }
66 | }
67 |
68 | public static void main( String[] args){
69 |
70 | new ExportTemplateTransformer("/resources/http4e-item.vm", new HttpBean()).doWrite(new StringWriter());
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/http4e-Feature/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | public class Translator {
6 | public static Object httppacketToFoldertab(String requestPacket){
7 | return null;
8 | }
9 | public static String foldertabToJavaSource(String requestPacket){
10 | return null;
11 | }}
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/http4e-Plugin/run.product.xml:
--------------------------------------------------------------------------------
1 |