Skip to content

Commit

Permalink
Merge pull request #401 from kolipakakondal/TISTUD-7569
Browse files Browse the repository at this point in the history
TISTUD-7569 The studio login dialog after entering wrong credentials
  • Loading branch information
kolipakakondal committed Jan 16, 2017
2 parents 033a829 + 8a610c4 commit 184152a
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Appcelerator Studio
* Copyright (c) 2016 by Appcelerator, Inc. All Rights Reserved.
* Proprietary and Confidential - This source code is not for redistribution
*/
package com.aptana.core.resources;

/**
* @author Kondal Kolipaka
*/
public interface ISocketMessageHandlerListener
{
/**
* Upon request cancelled, update the listeners which are registered.
*/
public void notifyRequestCancelled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @author pinnamuri
*/
public interface ISocketMessagesHandler
public interface ISocketMessagesHandler extends ISocketMessagesHandlerNotifier
{

/**
Expand All @@ -24,7 +24,8 @@ public interface ISocketMessagesHandler
*
* @param request
* @return
* @throws RequestCancelledException
*/
public JsonNode handleRequest(JsonNode request);
public JsonNode handleRequest(JsonNode request) throws RequestCancelledException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Appcelerator Studio
* Copyright (c) 2016 by Appcelerator, Inc. All Rights Reserved.
* Proprietary and Confidential - This source code is not for redistribution
*/
package com.aptana.core.resources;

/**
* @author Kondal Kolipaka
*/
public interface ISocketMessagesHandlerNotifier
{
/**
* @param listener
*/
public void addListener(ISocketMessageHandlerListener listener);

/**
* @param listener
*/
public void removeListener(ISocketMessageHandlerListener listener);

/**
* Update the registered listeners.
*/
public void update();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Appcelerator Studio
* Copyright (c) 2016 by Appcelerator, Inc. All Rights Reserved.
* Proprietary and Confidential - This source code is not for redistribution
*/
package com.aptana.core.resources;

/**
* @author Kondal Kolipaka
*/
public class RequestCancelledException extends Exception
{
private static final long serialVersionUID = 1998245433598939429L;

public RequestCancelledException()
{
}

public RequestCancelledException(String message)
{
super(message);
}

public RequestCancelledException(Exception e)
{
super(e);
}

public RequestCancelledException(String message, Exception e)
{
super(message, e);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Appcelerator Studio
* Copyright (c) 2016 by Appcelerator, Inc. All Rights Reserved.
* Proprietary and Confidential - This source code is not for redistribution
*/
package com.aptana.core.resources;

import java.util.ArrayList;
import java.util.List;

/**
* @author Kondal Kolipaka
*/
public abstract class SocketMessagesHandler implements ISocketMessagesHandler
{
private List<ISocketMessageHandlerListener> listeners;

public SocketMessagesHandler()
{
listeners = new ArrayList<ISocketMessageHandlerListener>();
}

public void addListener(ISocketMessageHandlerListener listener)
{
listeners.add(listener);
}

public void update()
{
for (ISocketMessageHandlerListener listener : listeners)
{
listener.notifyRequestCancelled();
}
}

public void removeListener(ISocketMessageHandlerListener listener)
{
listeners.remove(listener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
*/
package com.aptana.ui.handlers;

import com.aptana.core.resources.ISocketMessagesHandler;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

import com.aptana.core.resources.RequestCancelledException;
import com.aptana.core.resources.SocketMessagesHandler;
import com.aptana.core.util.StringUtil;
import com.aptana.ui.dialogs.InputMessageDialog;
import com.aptana.ui.dialogs.MultipleInputMessageDialog;
Expand All @@ -24,7 +28,7 @@
*
* @author pinnamuri
*/
public class AppcSocketMessagesHandler implements ISocketMessagesHandler
public class AppcSocketMessagesHandler extends SocketMessagesHandler
{

private static final String MESSAGE = "message"; //$NON-NLS-1$
Expand All @@ -46,7 +50,7 @@ public AppcSocketMessagesHandler(String actionName, String description)

}

public JsonNode handleRequest(JsonNode request)
public JsonNode handleRequest(JsonNode request) throws RequestCancelledException
{
final JsonNode type = request.path(TYPE);
if (QUESTION.equals(type.asText()))
Expand All @@ -64,7 +68,7 @@ else if (ERROR.equals(type.asText()))
return null;
}

private JsonNode handleQuestion(final JsonNode type)
private JsonNode handleQuestion(final JsonNode type) throws RequestCancelledException
{
final JsonNode questionNode = type.path(QUESTION);
final ObjectNode[] response = new ObjectNode[1];
Expand Down Expand Up @@ -101,10 +105,26 @@ public void run()
{
response[0] = null;
}

}
});

if (response[0] == null && isWorkbenchLaunched()) //To control dialog prompt cancel behaviour until we launch a studio.
{
throw new RequestCancelledException();
}

return response[0];
}

private boolean isWorkbenchLaunched()
{
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null)
{
return workbench.getWorkbenchWindowCount() == 0;
}
return false;
}

}

0 comments on commit 184152a

Please sign in to comment.