Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

JBIDE-19152 CordovaSim: Adding Basic FH support. Changing default proxy to "local" for non FeedHenry projects. Refactoring #124

Merged
merged 1 commit into from
Feb 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
<extension
point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
class="org.jboss.tools.vpe.cordovasim.eclipse.launch.internal.CordovaSimLaunchShortcut"
class="org.jboss.tools.vpe.cordovasim.eclipse.launch.CordovaSimLaunchShortcut"
id="org.jboss.tools.vpe.cordovasim.eclipse.launchShortcut"
label="Run with CordovaSim"
label="Run w/CordovaSim"
icon="icons/cordovasim_16.png"
modes="run">
<contextualLaunch>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007-2013 Red Hat, Inc.
* Copyright (c) 2013-2015 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Expand All @@ -12,10 +12,16 @@

import org.jboss.tools.vpe.cordovasim.eclipse.Activator;

/**
* @author "Yahor Radtsevich (yradtsevich)"
* @author "Ilya Buziuk (ibuziuk)"
*/
public class CordovaSimLaunchConstants {
public static final String LAUNCH_CONFIGURATION_ID = "org.jboss.tools.vpe.cordovasim.eclipse.cordovaSimLaunchConfigurationType"; //$NON-NLS-1$
public static final String PROJECT = ".PROJECT"; //$NON-NLS-1$
public static final String ROOT_FOLDER = Activator.PLUGIN_ID + ".ROOT_FOLDER"; //$NON-NLS-1$
public static final String START_PAGE = Activator.PLUGIN_ID + ".START_PAGE"; //$NON-NLS-1$
public static final String PORT = Activator.PLUGIN_ID + ".PORT"; //$NON-NLS-1$
}
public static final String FH = Activator.PLUGIN_ID + ".FH"; //$NON-NLS-1$
public static final String PROXY = Activator.PLUGIN_ID + ".PROXY"; //$NON-NLS-1$
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007-2013 Red Hat, Inc.
* Copyright (c) 2013-2015 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Expand All @@ -8,7 +8,7 @@
* Contributor:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.vpe.cordovasim.eclipse.launch.internal;
package org.jboss.tools.vpe.cordovasim.eclipse.launch;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -39,6 +39,7 @@
import org.eclipse.thym.core.engine.PlatformLibrary;
import org.jboss.tools.vpe.browsersim.browser.PlatformUtil;
import org.jboss.tools.vpe.cordovasim.eclipse.Activator;
import org.jboss.tools.vpe.cordovasim.eclipse.launch.internal.Messages;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
Expand Down Expand Up @@ -293,7 +294,7 @@ public static String getStartPageName(IFile configFile) {
return startPageName;
}

static IPath getRelativePath(IContainer container, IResource resource) {
public static IPath getRelativePath(IContainer container, IResource resource) {
if (resource == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013 Red Hat, Inc.
* Copyright (c) 2013-2015 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Expand All @@ -8,7 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*******************************************************************************/
package org.jboss.tools.vpe.cordovasim.eclipse.launch.internal;
package org.jboss.tools.vpe.cordovasim.eclipse.launch;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
Expand All @@ -25,8 +25,12 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ide.ResourceUtil;
import org.jboss.tools.vpe.cordovasim.eclipse.Activator;
import org.jboss.tools.vpe.cordovasim.eclipse.launch.CordovaSimLaunchConstants;
import org.jboss.tools.vpe.cordovasim.eclipse.launch.internal.CordovaSimLaunchConfigurationAutofillUtil;

/**
* @author "Yahor Radtsevich (yradtsevich)"
* @author "Ilya Buziuk (ibuziuk)"
*/
public class CordovaSimLaunchShortcut implements ILaunchShortcut {

@Override
Expand All @@ -45,7 +49,7 @@ public void launch(IEditorPart editor, String mode) {
}
}

private void launch(IProject project, String mode) {
protected void launch(IProject project, String mode) {
try {
ILaunchConfigurationType cordovaSimLaunchConfiguraionType = DebugPlugin.getDefault().getLaunchManager()
.getLaunchConfigurationType(CordovaSimLaunchConstants.LAUNCH_CONFIGURATION_ID);
Expand All @@ -67,7 +71,7 @@ private void launch(IProject project, String mode) {
}
}

private ILaunchConfigurationWorkingCopy createEmptyLaunchConfiguration(
protected ILaunchConfigurationWorkingCopy createEmptyLaunchConfiguration(
String namePrefix) throws CoreException {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType launchConfigurationType
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2015 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*******************************************************************************/
package org.jboss.tools.vpe.cordovasim.eclipse.launch;

/**
* @author Ilya Buziuk (ibuziuk)
*/
public enum RippleProxy {
DISABLED("disabled"), LOCAL("local"), REMOTE("remote"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

private final String value;

private RippleProxy(final String value) {
this.value = value;
}

public String getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ public static void fillLaunchConfiguraion(ILaunchConfigurationWorkingCopy launch
public static ILaunchConfiguration chooseLaunchConfiguration(ILaunchConfiguration[] configurations, IProject project) {
try {
for (ILaunchConfiguration configuration : configurations) {
String projectName;
projectName = configuration.getAttribute(CordovaSimLaunchConstants.PROJECT, (String) null);

if (projectName != null && projectName.equals(project.getName())) {
String projectName = configuration.getAttribute(CordovaSimLaunchConstants.PROJECT, (String) null);
String fh = configuration.getAttribute(CordovaSimLaunchConstants.FH, (String) null);
if (fh == null && projectName != null && projectName.equals(project.getName())) {
return configuration;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ public void launch(ILaunchConfiguration configuration, String mode,
String projectString = configuration.getAttribute(CordovaSimLaunchConstants.PROJECT, (String) null);
String rootFolderString = configuration.getAttribute(CordovaSimLaunchConstants.ROOT_FOLDER, (String) null);
String startPageString = configuration.getAttribute(CordovaSimLaunchConstants.START_PAGE, (String) null);
String proxy = configuration.getAttribute(CordovaSimLaunchConstants.PROXY, (String) null);
Integer port = null;
if (configuration.hasAttribute(CordovaSimLaunchConstants.PORT)) {
port = configuration.getAttribute(CordovaSimLaunchConstants.PORT, 0);
}

CordovaSimLauncher.launchCordovaSim(projectString, rootFolderString, startPageString, port);//TODO: NPE etc.
CordovaSimLauncher.launchCordovaSim(projectString, rootFolderString, startPageString, port, proxy);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.eclipse.ui.views.navigator.ResourceComparator;
import org.jboss.tools.vpe.cordovasim.eclipse.Activator;
import org.jboss.tools.vpe.cordovasim.eclipse.launch.CordovaSimLaunchConstants;
import org.jboss.tools.vpe.cordovasim.eclipse.launch.CordovaSimLaunchParametersUtil;

/**
* @author "Yahor Radtsevich (yradtsevich)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007-2013 Red Hat, Inc.
* Copyright (c) 2007-2015 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Expand Down Expand Up @@ -38,6 +38,7 @@
import org.jboss.tools.vpe.browsersim.util.BrowserSimUtil;
import org.jboss.tools.vpe.cordovasim.eclipse.Activator;
import org.jboss.tools.vpe.cordovasim.eclipse.internal.util.ServerUtil;
import org.jboss.tools.vpe.cordovasim.eclipse.launch.CordovaSimLaunchParametersUtil;
import org.jboss.tools.vpe.cordovasim.eclipse.server.internal.ServerCreator;
import org.jboss.tools.vpe.cordovasim.eclipse.server.internal.ServerStorage;

Expand All @@ -62,7 +63,7 @@ public class CordovaSimLauncher {
private static final String NOT_STANDALONE = BrowserSimLauncher.NOT_STANDALONE;

public static void launchCordovaSim(String projectString, String rootFolderString, String startPageString,
Integer port) {
Integer port, String proxy) {
List<String> parameters = new ArrayList<String>();
parameters.add(NOT_STANDALONE);

Expand Down Expand Up @@ -121,6 +122,10 @@ public static void launchCordovaSim(String projectString, String rootFolderStrin
parameters.add("-version"); //$NON-NLS-1$
parameters.add(cordovaVersion);
}
if (proxy != null) {
parameters.add("-proxy"); //$NON-NLS-1$
parameters.add(proxy);
}
launchCordovaSim(parameters);
} else {
showPortInUseMessage(port);
Expand Down Expand Up @@ -201,4 +206,4 @@ public void run() {
});
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.vpe.cordovasim.eclipse.Activator;
import org.jboss.tools.vpe.cordovasim.eclipse.internal.util.ServletUtil;
import org.jboss.tools.vpe.cordovasim.eclipse.launch.internal.CordovaSimLaunchParametersUtil;
import org.jboss.tools.vpe.cordovasim.eclipse.launch.CordovaSimLaunchParametersUtil;

/**
* @author Ilya Buziuk (ibuziuk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ <h1>Looks like what we have here is a failure to... emulate</h1>
</tr>
<tr style="display: none">
<td><label class="ui-text-label prefix-with-right-arrow">Proxy Port</label></td>
<td><input type="text" class="ui-state-default ui-corner-all" id="settings-xhr-proxy-local-port" value=""></td>
<td><input type="text" class="ui-state-default ui-corner-all" id="settings-xhr-proxy-local-port" value="" readonly="readonly"></td>
</tr>
<tr class="theme-switcher">
<td><label class="ui-text-label">Themes</label></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29569,12 +29569,12 @@ function _initialize() {

select.value = String(db.retrieve(PROXY_SETTING));

// default to remote if unknown value is found in db
// default to local if unknown value is found in db
if (!Object.keys(PROXY_SETTINGS_LIST).some(function (key) {
return select.value === PROXY_SETTINGS_LIST[key];
})) {
select.value = PROXY_SETTINGS_LIST.remote;
db.save(select.value);
select.value = PROXY_SETTINGS_LIST.local;
db.save(PROXY_SETTING, select.value);
}

if (select.value === PROXY_SETTINGS_LIST.local) {
Expand Down Expand Up @@ -55108,6 +55108,7 @@ self = module.exports = {

}());
if (!localStorage2.ripple) {
var csRippleProxy = window.csRippleProxy || "local";
var defaultValues = {"tinyhippos-ui-application-state-cordova":
{
"id":"tinyhippos-ui-application-state-cordova",
Expand Down Expand Up @@ -55143,14 +55144,14 @@ if (!localStorage2.ripple) {
{
"id":"tinyhippos-settings-xhr-proxy-setting",
"key":"settings-xhr-proxy-setting",
"value":"remote",
"value": csRippleProxy,
"prefix":"tinyhippos-"
},
"tinyhippos-settings-xhr-proxy-local-port":
{
"id":"tinyhippos-settings-xhr-proxy-local-port",
"key":"settings-xhr-proxy-local-port",
"value":location.port,
"value": location.port,
"prefix":"tinyhippos-"
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007-2013 Red Hat, Inc.
* Copyright (c) 2007-2015 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Expand All @@ -22,13 +22,15 @@

/**
* @author Yahor Radtsevich (yradtsevich)
* @author Ilya Buziuk (ibuziuk)
*/
public class CordovaSimArgs {
private static String rootFolder;
private static String homeUrl;
private static String cordovaVersion;
private static int port;
private static boolean restartRequired;
private static String proxy;

public static void parseArgs(String[] args) {
List<String> params = new ArrayList<String>(Arrays.asList(args));
Expand All @@ -48,9 +50,17 @@ public static void parseArgs(String[] args) {
params.remove(versionParameterIndex);
cordovaVersion = params.remove(versionParameterIndex);
} else {
cordovaVersion = "3.1.0"; //$NON-NLS-1$ Using cordova-3.1.0.js
cordovaVersion = "3.5.0"; //$NON-NLS-1$ Using cordova-3.5.0.js
}


int proxyIndex = params.indexOf("-proxy"); //$NON-NLS-1$
if (proxyIndex >= 0) {
params.remove(proxyIndex);
proxy = params.remove(proxyIndex);
} else {
proxy = null;
}

if (params.size() > 0) {
homeUrl = params.remove(params.size() - 1); // the parameter before the last one
try {
Expand Down Expand Up @@ -81,7 +91,6 @@ public static String getRootFolder() {
return rootFolder;
}


public static int getPort() {
return port;
}
Expand All @@ -102,9 +111,13 @@ public static String getHomeUrl() {
return homeUrl;
}

public static String getProxy() {
return proxy;
}

private static int getPortFromURL(String homeUrl) throws MalformedURLException {
URL url = new URL(homeUrl);
return url.getPort();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,19 @@ protected SpecificPreferences create(String selectedDeviceId, boolean useSkins,
@Override
protected void sendRestartCommand() {
CordovaSimArgs.setRestartRequired(true);
System.out.println(CORDOVASIM_RESTART_COMMAND + PARAMETER_DELIMITER + CordovaSimArgs.getRootFolder()
System.out.println(generateRestartCommand()); // Fire restart command @see CordovaSimRestartCallback.java
}

private String generateRestartCommand() {
String command = CORDOVASIM_RESTART_COMMAND + PARAMETER_DELIMITER + CordovaSimArgs.getRootFolder()
+ PARAMETER_DELIMITER + CordovaSimArgs.getHomeUrl() + PARAMETER_DELIMITER
+ "-version" + PARAMETER_DELIMITER + CordovaSimArgs.getCordovaVersion()); //$NON-NLS-1$
+ "-version" + PARAMETER_DELIMITER + CordovaSimArgs.getCordovaVersion(); //$NON-NLS-1$

String proxy = CordovaSimArgs.getProxy();
if (proxy != null) {
command += PARAMETER_DELIMITER + "-proxy" + PARAMETER_DELIMITER + proxy; //$NON-NLS-1$
}
return command;
}

}