Skip to content

Commit

Permalink
jbide-24797 - apply default Eclipse code formatter
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitrii Bocharov <dbocharo@redhat.com>
  • Loading branch information
bdshadow authored and robstryker committed Dec 15, 2017
1 parent fbd9f5e commit eb176cb
Show file tree
Hide file tree
Showing 867 changed files with 18,736 additions and 20,995 deletions.
314 changes: 314 additions & 0 deletions eclipse-formatter.xml

Large diffs are not rendered by default.

Expand Up @@ -7,11 +7,11 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
******************************************************************************/
package org.jboss.tools.openshift.cdk.server.core.internal;

public interface CDKConstants {

public static final String SPACE = " ";
public static final String VAGRANT = "vagrant";
public static final String VAGRANT_CMD_STATUS = "status";
Expand All @@ -20,23 +20,21 @@ public interface CDKConstants {
public static final String VAGRANT_CMD_SERVICE_MANAGER = "service-manager";
public static final String VAGRANT_CMD_SERVICE_MANAGER_ARG_ENV = "env";
public static final String VAGRANT_FLAG_MACHINE_READABLE = "--machine-readable";
public static final String VAGRANT_FLAG_NO_COLOR= "--no-color";
public static final String VAGRANT_FLAG_NO_COLOR = "--no-color";
public static final String VAGRANT_FLAG_PROVIDER_NAME = "provider-name";

public static final String CDK_ENV_SUB_USERNAME = "SUB_USERNAME";
public static final String CDK_ENV_SUB_PASSWORD = "SUB_PASSWORD";
public static final String CDK3_ENV_SUB_USER_KEY = "MINISHIFT_USERNAME";
public static final String CDK3_ENV_SUB_PASS_KEY = "MINISHIFT_PASSWORD";



public static final String CDK_RESOURCE_VAGRANTFILE = "Vagrantfile";
public static final String CDK_RESOURCE_DOTMINISHIFT= ".minishift";
public static final String CDK_RESOURCE_DOTCDK= ".cdk";
public static final String CDK_RESOURCE_CDK= "cdk";
public static final String CDK_RESOURCE_DOTMINISHIFT = ".minishift";
public static final String CDK_RESOURCE_DOTCDK = ".cdk";
public static final String CDK_RESOURCE_CDK = "cdk";

public static final String CDK32_RESOURCE_PROFILES = "profiles";


// Response strings from a status call
static final String STATE = "state";
static final String STATE_HUMAN_SHORT = "state-human-short";
Expand Down
Expand Up @@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
******************************************************************************/
package org.jboss.tools.openshift.cdk.server.core.internal;

import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
Expand All @@ -26,26 +26,25 @@ public class CDKCoreActivator extends BaseUIPlugin {

// The shared instance
private static CDKCoreActivator plugin;

/**
* The constructor
*/
public CDKCoreActivator() {
}


private UnitedServerListener configureDependentFrameworksListener;

/*
* NOT API, public only for testing
*/
public UnitedServerListener getConfigureDependentFrameworksListener() {
if( configureDependentFrameworksListener == null ) {
if (configureDependentFrameworksListener == null) {
configureDependentFrameworksListener = new ConfigureDependentFrameworksListener();
}
return configureDependentFrameworksListener;
}

/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
Expand Down Expand Up @@ -76,6 +75,7 @@ public void stop(BundleContext context) throws Exception {
public static CDKCoreActivator getDefault() {
return plugin;
}

/**
* Get the IPluginLog for this plugin. This method
* helps to make logging easier, for example:
Expand All @@ -95,7 +95,6 @@ public static IPluginLog pluginLog() {
public static StatusFactory statusFactory() {
return getDefault().statusFactoryInternal();
}


/**
* Create your shared images instance. Clients are expected to override this
Expand All @@ -106,6 +105,7 @@ protected BaseUISharedImages createSharedImages() {
}

public static final String CDK_WIZBAN = "icons/cdk_box_130x65.png";

private static class CDKSharedImages extends BaseUISharedImages {
public CDKSharedImages(Bundle pluginBundle) {
super(pluginBundle);
Expand Down
Expand Up @@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
******************************************************************************/
package org.jboss.tools.openshift.cdk.server.core.internal;

import java.io.File;
Expand All @@ -23,43 +23,43 @@

public class MinishiftBinaryUtility {
private static final String MINISHIFT_LOCATION_LINUX = "/usr/bin/minishift";

// Seems weird? See https://github.com/mitchellh/vagrant/issues/1652
private static final String MINISHIFT_LOCATION_WINDOWS = "C:\\minishift.exe";

private static CommandLocationBinary binary;

public static String getMinishiftLocation() {
return findMinishiftLocation();
}

public static String getMinishiftLocation(IServer server) {
if( server != null ) {
String minishiftFile = server.getAttribute(CDK32Server.MINISHIFT_FILE, (String)null);
if( minishiftFile != null )
if (server != null) {
String minishiftFile = server.getAttribute(CDK32Server.MINISHIFT_FILE, (String) null);
if (minishiftFile != null)
return minishiftFile;

try {
ILaunchConfiguration lc = server.getLaunchConfiguration(false, new NullProgressMonitor());
return getMinishiftLocation(lc);
} catch(CoreException ce) {
} catch (CoreException ce) {
// ignore, this is non-critical
}
}
return findMinishiftLocation();
}

public static String getMinishiftLocation(ILaunchConfiguration lc) throws CoreException {
if( lc != null ) {
String ret = lc.getAttribute(IExternalLaunchConstants.ATTR_LOCATION, (String)null);
if( ret != null && new File(ret).exists())
return ret;
if (lc != null) {
String ret = lc.getAttribute(IExternalLaunchConstants.ATTR_LOCATION, (String) null);
if (ret != null && new File(ret).exists())
return ret;
}
return findMinishiftLocation();
}

private static String findMinishiftLocation() {
if( binary == null ) {
if (binary == null) {
binary = new CommandLocationBinary("minishift");
binary.addPlatformLocation(Platform.OS_LINUX, MINISHIFT_LOCATION_LINUX);
binary.addPlatformLocation(Platform.OS_WIN32, MINISHIFT_LOCATION_WINDOWS);
Expand Down
Expand Up @@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
******************************************************************************/
package org.jboss.tools.openshift.cdk.server.core.internal;

import java.io.File;
Expand All @@ -22,39 +22,39 @@

public class VagrantBinaryUtility {
private static final String VAGRANT_LOCATION_LINUX = "/usr/bin/vagrant";

// Seems weird? See https://github.com/mitchellh/vagrant/issues/1652
private static final String VAGRANT_LOCATION_WINDOWS = "C:\\HashiCorp\\Vagrant\\bin\\vagrant.exe";

private static CommandLocationBinary binary;

public static String getVagrantLocation() {
return findVagrantLocation();
}

public static String getVagrantLocation(IServer server) {
if( server != null ) {
if (server != null) {
try {
ILaunchConfiguration lc = server.getLaunchConfiguration(false, new NullProgressMonitor());
return getVagrantLocation(lc);
} catch(CoreException ce) {
} catch (CoreException ce) {
// ignore, this is non-critical
}
}
return findVagrantLocation();
}

public static String getVagrantLocation(ILaunchConfiguration lc) throws CoreException {
if( lc != null ) {
String ret = lc.getAttribute(IExternalLaunchConstants.ATTR_LOCATION, (String)null);
if( ret != null && new File(ret).exists())
return ret;
if (lc != null) {
String ret = lc.getAttribute(IExternalLaunchConstants.ATTR_LOCATION, (String) null);
if (ret != null && new File(ret).exists())
return ret;
}
return findVagrantLocation();
}

private static String findVagrantLocation() {
if( binary == null ) {
if (binary == null) {
binary = new CommandLocationBinary("vagrant");
binary.addPlatformLocation(Platform.OS_LINUX, VAGRANT_LOCATION_LINUX);
binary.addPlatformLocation(Platform.OS_WIN32, VAGRANT_LOCATION_WINDOWS);
Expand Down
Expand Up @@ -14,7 +14,7 @@
import org.jboss.tools.openshift.cdk.server.core.internal.CDKCoreActivator;

public abstract class AbstractCDKPoller implements IServerStatePoller2 {

protected IServer server;
protected boolean canceled, done;
protected boolean state;
Expand All @@ -26,7 +26,6 @@ public IServer getServer() {
return server;
}


@Override
public void beginPolling(IServer server, boolean expectedState) throws PollingException {
this.server = server;
Expand All @@ -35,76 +34,75 @@ public void beginPolling(IServer server, boolean expectedState) throws PollingEx
this.state = !expectedState;
launchThread();
}

protected abstract void launchThread();

protected void launchThread(String name) {
Thread t = new Thread(new Runnable(){
Thread t = new Thread(new Runnable() {
@Override
public void run() {
pollerRun();
}
}, "CDK Poller"); //$NON-NLS-1$
t.start();
}



protected void pollerRun() {
setStateInternal(false, state);
Map<String,String> env = createEnvironment(server);
while(aborted == null && !canceled && !done) {
Map<String, String> env = createEnvironment(server);
while (aborted == null && !canceled && !done) {
IStatus stat = onePingSafe(server, env);
int status = stat.getSeverity();
boolean completeUp = ( status == IStatus.OK && expectedState);
boolean completeUp = (status == IStatus.OK && expectedState);
boolean completeDown = (status == IStatus.ERROR && !expectedState);
if( completeUp || completeDown) {
if (completeUp || completeDown) {
setStateInternal(true, expectedState);
}
try {
Thread.sleep(700);
} catch(InterruptedException ie) {} // ignore
} catch (InterruptedException ie) {
} // ignore
}
}

protected abstract Map<String, String> createEnvironment(IServer server);

protected synchronized void setStateInternal(boolean done, boolean state) {
this.done = done;
this.state = state;
}



@Override
public IStatus getCurrentStateSynchronous(IServer server) {
Map<String, String> env = createEnvironment(server);
int severity = onePingSafe(server, env).getSeverity();
if( severity == IStatus.OK ) {
int severity = onePingSafe(server, env).getSeverity();
if (severity == IStatus.OK) {
return new Status(IStatus.OK, CDKCoreActivator.PLUGIN_ID, "CDK Instance is Up");
} else if( severity == IStatus.ERROR){
} else if (severity == IStatus.ERROR) {
return new Status(IStatus.ERROR, CDKCoreActivator.PLUGIN_ID, "CDK Instance is shutoff");
} else {
return new Status(IStatus.INFO, CDKCoreActivator.PLUGIN_ID, "CDK Instance is indeterminate");
}
}
protected IStatus onePingSafe(IServer server, Map<String,String> env) {
try {
IStatus ret = onePing(server, env);
return ret;
} catch(PollingException pe) {
aborted = pe;

protected IStatus onePingSafe(IServer server, Map<String, String> env) {
try {
IStatus ret = onePing(server, env);
return ret;
} catch (PollingException pe) {
aborted = pe;
} catch (TimeoutException te) {
aborted = new PollingException(te.getMessage(), te);
} catch (IOException ioe) {
CDKCoreActivator.pluginLog().logError(ioe.getMessage(), ioe);
}
return CDKCoreActivator.statusFactory().infoStatus(CDKCoreActivator.PLUGIN_ID, "Response status indicates the CDK is starting.");
return CDKCoreActivator.statusFactory().infoStatus(CDKCoreActivator.PLUGIN_ID,
"Response status indicates the CDK is starting.");
}

protected abstract IStatus onePing(IServer server, Map<String, String> env)
throws PollingException, IOException, TimeoutException;

@Override
public synchronized boolean isComplete() throws PollingException, RequiresInfoException {
return done;
Expand Down Expand Up @@ -132,13 +130,13 @@ public synchronized void cancel(int type) {
public PollingException getPollingException() {
return aborted;
}

@Override
public void provideCredentials(Properties credentials) {
// TODO Auto-generated method stub

}

@Override
public IServerStatePollerType getPollerType() {
// TODO Auto-generated method stub
Expand All @@ -148,8 +146,8 @@ public IServerStatePollerType getPollerType() {
@Override
public void setPollerType(IServerStatePollerType type) {
// TODO Auto-generated method stub
}

}

@Override
public List<String> getRequiredProperties() {
Expand Down

0 comments on commit eb176cb

Please sign in to comment.