本文整理匯總了Java中ca.sqlpower.util.UserPrompter.UserPromptOptions類的典型用法代碼示例。如果您正苦於以下問題:Java UserPromptOptions類的具體用法?Java UserPromptOptions怎麽用?Java UserPromptOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
UserPromptOptions類屬於ca.sqlpower.util.UserPrompter包,在下文中一共展示了UserPromptOptions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createNewServerSession
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public static ProjectLocation createNewServerSession(SPServerInfo serviceInfo, String name,
CookieStore cookieStore, UserPrompterFactory userPrompterFactory)
throws URISyntaxException, ClientProtocolException, IOException, JSONException {
HttpClient httpClient = ClientSideSessionUtils.createHttpClient(serviceInfo, cookieStore);
try {
HttpUriRequest request = new HttpGet(getServerURI(serviceInfo, "/" + REST_TAG + "/jcr/projects/new", "name=" + name));
JSONMessage message = httpClient.execute(request, new JSONResponseHandler());
JSONObject response = new JSONObject(message.getBody());
return new ProjectLocation(
response.getString("uuid"),
response.getString("name"),
serviceInfo);
} catch (AccessDeniedException e) {
userPrompterFactory.createUserPrompter("You do not have sufficient privileges to create a new workspace.",
UserPromptType.MESSAGE,
UserPromptOptions.OK,
UserPromptResponse.OK,
"OK", "OK").promptUser("");
return null;
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例2: deleteServerWorkspace
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public static void deleteServerWorkspace(ProjectLocation projectLocation, CookieStore cookieStore,
UserPrompterFactory userPrompterFactory) throws URISyntaxException, ClientProtocolException, IOException {
SPServerInfo serviceInfo = projectLocation.getServiceInfo();
HttpClient httpClient = ClientSideSessionUtils.createHttpClient(serviceInfo, cookieStore);
try {
executeServerRequest(httpClient, projectLocation.getServiceInfo(),
"/" + ClientSideSessionUtils.REST_TAG + "/jcr/" + projectLocation.getUUID() + "/delete",
new JSONResponseHandler());
} catch (AccessDeniedException e) {
userPrompterFactory.createUserPrompter("You do not have sufficient privileges to delete the selected workspace.",
UserPromptType.MESSAGE,
UserPromptOptions.OK,
UserPromptResponse.OK,
"OK", "OK").promptUser("");
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例3: displayCleanupErrors
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
/**
* This method will display the cleanup errors to the user. If the
* user prompter factory given is null the errors will be logged instead.
*/
public static void displayCleanupErrors(@Nonnull CleanupExceptions cleanupObject,
UserPrompterFactory upf) {
if (upf != null) {
if (!cleanupObject.isCleanupSuccessful()) {
StringBuffer message = new StringBuffer();
message.append("The following errors occurred during closing\n");
for (String error : cleanupObject.getErrorMessages()) {
message.append(" " + error + "\n");
}
for (Exception exception : cleanupObject.getExceptions()) {
message.append(" " + exception.getMessage() + "\n");
logger.error("Exception during cleanup", exception);
}
UserPrompter up = upf.createUserPrompter(
message.toString(),
UserPromptType.MESSAGE, UserPromptOptions.OK, UserPromptResponse.OK,
null, "OK");
up.promptUser();
}
} else {
logCleanupErrors(cleanupObject);
}
}
示例4: addImportedWorkspaceContentToWorkspace
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
/**
* Call this method to add the {@link WabitObject}s in the loaded workspaces
* to the given session . This is the last step to importing a file into
* Wabit workspace.
* <p>
* If importing is done on multiple threads this operation must be done on
* the event dispatch thread. This should only be called once for each DAO
* or the same workspace will be added to the context multiple times.
*
* @param session
* The session that will have {@link WabitObject}s added to it.
* Null should not be passed into this method.
*/
public void addImportedWorkspaceContentToWorkspace(WabitSession session) {
if (session == null) {
context.createUserPrompter("Select a workspace to import into.", UserPromptType.MESSAGE,
UserPromptOptions.OK, UserPromptResponse.OK, null);
return;
}
if (cancelled.get()) return;
try {
final WabitWorkspace workspace = session.getWorkspace();
int importObjectCount = 0;
WabitSession importingSession = saxHandler.getSession();
final WabitWorkspace importingWorkspace = importingSession.getWorkspace();
importObjectCount += importingWorkspace.mergeIntoWorkspace(workspace);
logger.debug("Imported " + importObjectCount + " objects into " + session.getWorkspace().getName());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例5: close
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
@Override
public boolean close() {
logger.debug("Closing Client Session");
try {
HttpUriRequest request = new HttpDelete(getServerURI(workspaceLocation.getServiceInfo(),
"session/" + getWorkspace().getUUID()));
outboundHttpClient.execute(request, new BasicResponseHandler());
} catch (Exception e) {
try {
logger.error(e);
getContext().createUserPrompter("Cannot access the server to close the server session",
UserPromptType.MESSAGE, UserPromptOptions.OK, UserPromptResponse.OK, UserPromptResponse.OK, "OK");
} catch (Throwable t) {
//do nothing here because we failed on logging the error.
}
}
outboundHttpClient.getConnectionManager().shutdown();
updater.interrupt();
if (dataSourceCollection != null) {
dataSourceCollectionUpdater.detach(dataSourceCollection);
}
return super.close();
}
示例6: createUserPrompter
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public UserPrompter createUserPrompter(String question,
UserPromptType responseType, UserPromptOptions optionType,
UserPromptResponse defaultResponseType, Object defaultResponse,
String... buttonNames) {
if (UserPromptType.TEXT.equals(responseType) && optionType.equals(UserPromptOptions.OK_CANCEL)) {
return new TextUserPrompter(owner, question, defaultResponseType, defaultResponse, buttonNames[0], buttonNames[1]);
} else {
return new DialogUserPrompter(optionType, defaultResponseType, owner, question, buttonNames);
}
}
示例7: createDatabaseUserPrompter
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public UserPrompter createDatabaseUserPrompter(String question,
List<Class<? extends SPDataSource>> dsTypes,
UserPromptOptions optionType,
UserPromptResponse defaultResponseType, Object defaultResponse,
DataSourceCollection<SPDataSource> dsCollection,
String... buttonNames) {
return new DataSourceUserPrompter(question, optionType, defaultResponseType, (SPDataSource) defaultResponse,
owner, question, dsCollection, dsTypes, buttonNames);
}
示例8: refreshInfoList
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
protected void refreshInfoList() {
DefaultListModel model = (DefaultListModel) projects.getModel();
model.removeAllElements();
SPServerInfo serviceInfo = getSelectedServerInfo();
if (serviceInfo != null) {
try {
List<ProjectLocation> projectLocations = getProjectLocations();
// Sorts the project locations alphabetically
Collections.sort(projectLocations, new Comparator<ProjectLocation>() {
public int compare(ProjectLocation proj1, ProjectLocation proj2) {
return proj1.getName().compareToIgnoreCase(proj2.getName());
}
});
model.clear();
for (ProjectLocation pl : projectLocations) {
model.addElement(pl);
}
connected = true;
} catch (Exception ex) {
model.removeAllElements();
model.addElement("Unable to get projects from server");
connected = false;
upf.createUserPrompter("Server Unavailable",
UserPromptType.MESSAGE,
UserPromptOptions.OK,
UserPromptResponse.OK,
"OK", "OK").promptUser("");
}
refreshPanel();
} else {
model.addElement("No Server Selected");
connected = false;
refreshPanel();
}
}
示例9: getWorkspaceNames
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public static List<ProjectLocation> getWorkspaceNames(SPServerInfo serviceInfo,
CookieStore cookieStore, UserPrompterFactory upf)
throws IOException, URISyntaxException, JSONException {
HttpClient httpClient = ClientSideSessionUtils.createHttpClient(serviceInfo, cookieStore);
try {
HttpUriRequest request = new HttpGet(getServerURI(serviceInfo, "/" + ClientSideSessionUtils.REST_TAG + "/jcr/projects"));
JSONMessage message = httpClient.execute(request, new JSONResponseHandler());
if (message.getStatusCode() == 412) { //precondition failed
upf.createUserPrompter(message.getBody(), UserPromptType.MESSAGE,
UserPromptOptions.OK, UserPromptResponse.OK, null, "OK").promptUser();
}
List<ProjectLocation> workspaces = new ArrayList<ProjectLocation>();
JSONArray response = new JSONArray(message.getBody());
for (int i = 0; i < response.length(); i++) {
JSONObject workspace = (JSONObject) response.get(i);
workspaces.add(new ProjectLocation(
workspace.getString("uuid"),
workspace.getString("name"),
serviceInfo));
}
return workspaces;
} catch (AccessDeniedException e) {
throw e;
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例10: uploadProject
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public static ProjectLocation uploadProject(SPServerInfo serviceInfo, String name, File project, UserPrompterFactory session, CookieStore cookieStore)
throws URISyntaxException, ClientProtocolException, IOException, JSONException {
HttpClient httpClient = ClientSideSessionUtils.createHttpClient(serviceInfo, cookieStore);
try {
MultipartEntity entity = new MultipartEntity();
ContentBody fileBody = new FileBody(project);
ContentBody nameBody = new StringBody(name);
entity.addPart("file", fileBody);
entity.addPart("name", nameBody);
HttpPost request = new HttpPost(ClientSideSessionUtils.getServerURI(serviceInfo, "/" + ClientSideSessionUtils.REST_TAG + "/jcr", "name=" + name));
request.setEntity(entity);
JSONMessage message = httpClient.execute(request, new JSONResponseHandler());
JSONObject response = new JSONObject(message.getBody());
return new ProjectLocation(
response.getString("uuid"),
response.getString("name"),
serviceInfo);
} catch (AccessDeniedException e) {
session.createUserPrompter("You do not have sufficient privileges to create a new workspace.",
UserPromptType.MESSAGE,
UserPromptOptions.OK,
UserPromptResponse.OK,
"OK", "OK").promptUser("");
return null;
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例11: createDatabaseUserPrompter
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public UserPrompter createDatabaseUserPrompter(String question,
List<Class<? extends SPDataSource>> dsTypes,
UserPromptOptions optionType,
UserPromptResponse defaultResponseType, Object defaultResponse,
DataSourceCollection<SPDataSource> dsCollection,
String... buttonNames) {
return new DefaultUserPrompter(optionType, defaultResponseType, defaultResponse);
}
示例12: close
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public boolean close() {
if (getDDLGenerator() != null) {
if (getDDLGenerator().getTargetCatalog() != null) {
prefs.put(projectLocation.getUUID() + ".targetCatalog", getDDLGenerator().getTargetCatalog());
}
if (getDDLGenerator().getTargetSchema() != null) {
prefs.put(projectLocation.getUUID() + ".targetSchema", getDDLGenerator().getTargetSchema());
}
prefs.put(projectLocation.getUUID() + ".ddlg", getDDLGenerator().getClass().getName());
}
try {
//TODO: Figure out how to de-register the session &c.
} catch (Exception e) {
logger.error(e);
delegateSession.createUserPrompterFactory().createUserPrompter("Cannot access the server to close the server session",
UserPromptType.MESSAGE,
UserPromptOptions.OK,
UserPromptResponse.OK,
UserPromptResponse.OK, "OK").promptUser("");
}
updater.interrupt();
outboundHttpClient.getConnectionManager().shutdown();
if (dataSourceCollection != null) {
dataSourceCollectionUpdater.detach(dataSourceCollection);
}
getSystemWorkspace().removeSPListener(deletionListener);
return delegateSession.close();
}
示例13: createDatabaseUserPrompter
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public UserPrompter createDatabaseUserPrompter(String question,
List<Class<? extends SPDataSource>> dsTypes,
UserPromptOptions optionType,
UserPromptResponse defaultResponseType, Object defaultResponse,
DataSourceCollection<SPDataSource> dsCollection,
String... buttonNames) {
return upfMissingLoadedDB.createDatabaseUserPrompter(question, dsTypes, optionType, defaultResponseType,
defaultResponse, dsCollection, buttonNames);
}
示例14: createDatabaseUserPrompter
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public UserPrompter createDatabaseUserPrompter(String question,
List<Class<? extends SPDataSource>> dsTypes,
UserPromptOptions optionType,
UserPromptResponse defaultResponseType, Object defaultResponse,
DataSourceCollection<SPDataSource> dsCollection,
String... buttonNames) {
return upf.createDatabaseUserPrompter(question, dsTypes, optionType, defaultResponseType,
defaultResponse, dsCollection, buttonNames);
}
示例15: createUserPrompter
import ca.sqlpower.util.UserPrompter.UserPromptOptions; //導入依賴的package包/類
public UserPrompter createUserPrompter(String question,
UserPromptType responseType, UserPromptOptions optionType,
UserPromptResponse defaultResponseType, Object defaultResponse,
String... buttonNames) {
return upf.createUserPrompter(question, responseType, optionType, defaultResponseType,
defaultResponse, buttonNames);
}