📄 guistate.java
字号:
/**
* Displays a warning message for debug purposes, iff debuging is enabled
*
* @param headline
* @param message
*/
public static void displayWarning(Component comp, String headline, String message){
JOptionPane.showMessageDialog(comp, message, headline, JOptionPane.WARNING_MESSAGE);
}
public static void generateDummyData() {
try {
System.out.println("Loading dummy data to TestCollection:");
URI query1 = new URI("http://127.0.0.1/queries/1.1/1personbicyclecar_price_service.owls");
URI query2 = new URI("http://127.0.0.1/queries/1.1/book_price_service.owls");
TestCollection.getInstance().addQuery(query1);
System.out.println("--------------------------------------");
TestCollection.getInstance().addQuery(query2);
TestCollection.getInstance().addService(new URI("http://127.0.0.1/services/1.1/_3WheeledAudiCarprice_service.owls"));
TestCollection.getInstance().addService(new URI("http://127.0.0.1/services/1.1/__destination_MyOfficeservice.owls"));
TestCollection.getInstance().addService(new URI("http://127.0.0.1/services/1.1/__luxuryhotel_Heidelburgservice.owls"));
TestCollection.getInstance().addService(new URI("http://127.0.0.1/services/1.1/_aps-slrpricereport_Musuemservice.owls"));
TestCollection.getInstance().addService(new URI("http://127.0.0.1/services/1.1/_author_CompJservice.owls"));
TestCollection.getInstance().addService(new URI("http://127.0.0.1/services/1.1/_author_DMservice.owls"));
TestCollection.getInstance().addServiceToAnswerset(query1,new URI("http://127.0.0.1/services/1.1/_3WheeledAudiCarprice_service.owls"));
TestCollection.getInstance().addServiceToAnswerset(query1,new URI("http://127.0.0.1/services/1.1/__destination_MyOfficeservice.owls"));
TestCollection.getInstance().addServiceToAnswerset(query1,new URI("http://127.0.0.1/services/1.1/__luxuryhotel_Heidelburgservice.owls"));
TestCollection.getInstance().addServiceToAnswerset(query2,new URI("http://127.0.0.1/services/1.1/_aps-slrpricereport_Musuemservice.owls"));
TestCollection.getInstance().addServiceToAnswerset(query2,new URI("http://127.0.0.1/services/1.1/_author_CompJservice.owls"));
TestCollection.getInstance().addServiceToAnswerset(query2,new URI("http://127.0.0.1/services/1.1/_author_DMservice.owls"));
//TestCollection.getInstance().removeService(new URI("http://www.develin.de/service1"));
System.out.println("Before:");
System.out.println("Services : " + TestCollection.getInstance().getServices().size());
System.out.println("Requests : " + TestCollection.getInstance().getQueries().size());
System.out.println("Answerset 1 : " + TestCollection.getInstance().getAnswerset(query1).size());
System.out.println("Answerset 2 : " + TestCollection.getInstance().getAnswerset(query2).size());
System.out.println("--------------------------------------");
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public TaskContent getStepContent(int task, int step) throws Exception {
TaskContent[] content =(TaskContent[])wizardContent.get(new Integer(task));
if (content==null) {
//System.out.println("No content loaded for wizard");
throw new Exception("No content loaded for wizard");
}
if (content[step-1]==null) {
//System.out.println("No content for step " + (step-1) + ", is there is content for step+1 " + (content[step]==null));
throw new Exception("No content for step " + (step-1) + ", is there is content for step+1 " + (content[step]==null));
}
if ( ( step > content.length) || ( (step-1) < 0) ) {
//System.out.println("Wizard step " + step + " of task " + task + " does not exist.\n");
throw new Exception("Wizard step " + step + " of task " + task + " does not exist.\n");
}
// Step(" + (content[step]==null) + ")"
// + "Content(" + (wizardContent.size()) + ") Task(" + (content!=null) + ")")
return content[step-1];
}
public TaskContent getCurrentStepContent() throws Exception {
return getStepContent(currentTask,currentStep);
}
private void processLine(String line, Map wizardContent) {
TaskContent contentItem = new TaskContent(line);
TaskContent[] tasks;
if (wizardContent.containsKey(contentItem.task))
tasks = (TaskContent[])wizardContent.get(contentItem.task);
else
tasks = new TaskContent[contentItem.totalSteps];
if ( ((contentItem.step-1)<tasks.length) &&
((contentItem.step-1)>=0) )
tasks[contentItem.step-1] = contentItem;
else
GUIState.displayWarning(this.getClass().toString()+"|processLine", "Current step does not fit in range: 0 > " + (contentItem.step-1) + " >" + tasks.length);
wizardContent.put(contentItem.task,tasks);
}
public boolean hasNextStep() {
try {
TaskContent[] taskContent =(TaskContent[])wizardContent.get(new Integer(currentTask));
TaskContent content = getStepContent(currentTask,currentStep);
return ( (currentStep<taskContent.length) && (currentStep < content.totalSteps) && (taskContent[currentStep]!=null) );
} catch (Exception e) {
GUIState.displayWarning(getClass().toString() + "|setNextStep:",e.getClass().toString()+ "\n" + e.getMessage());
e.printStackTrace();
return false;
}
}
public void setNextStep() {
try {
TaskContent content = getStepContent(currentTask,currentStep);
if (hasNextStep()) {
currentStep++;
}
else
GUIState.displayWarning(getClass().toString() + "|setNextStep:", "No next step: " + currentStep + "<" + content.totalSteps);
TestCollection.getInstance().updateData();
} catch (Exception e) {
GUIState.displayWarning(getClass().toString() + "|setNextStep:",e.getClass().toString()+ "\n" + e.getMessage());
e.printStackTrace();
}
}
public boolean hasLastStep() {
TaskContent[] taskContent =(TaskContent[])wizardContent.get(new Integer(currentTask));
return ( (currentStep > 1) && (taskContent[currentStep-2]!=null) );
}
public void setLastStep() {
try {
if (hasLastStep())
currentStep--;
else
GUIState.displayWarning(getClass().toString() + "|setLastStep:","No last step current step is " + currentStep);
TestCollection.getInstance().updateData();
} catch (Exception e) {
GUIState.displayWarning(getClass().toString() + "|setNextStep:",e.getClass().toString()+ "\n" + e.getMessage());
e.printStackTrace();
}
}
/**
* Loads the texts and steps for the Wizard from the included data/wizard.dat
*
*/
private void loadWizardContent() {
try {
Map wizardContent = new HashMap();
String line;
BufferedReader reader = new BufferedReader(new FileReader(new File(getClass().getResource("/data/wizard.dat").getFile())));
while( (line = reader.readLine()) != null) {
processLine(line,wizardContent);
}
this.wizardContent = wizardContent;
setCurrentTask(GUIState.NO_TASK);
setCurrentStep(1);
} catch (FileNotFoundException e) {
//GUIState.displayWarning(this.getClass().toString() + ": " + e.getClass().toString(), e.getMessage());
// owlsmx.io.ErrorLog.instanceOf().report(this.getClass().toString() + e.getMessage());
} catch (IOException e) {
owlsmx.io.ErrorLog.instanceOf().report(this.getClass().toString() + e.getMessage());
// e.printStackTrace();
} catch(Exception e) {
owlsmx.io.ErrorLog.instanceOf().report(this.getClass().toString() + e.getMessage());
}
}
/**
* @return Returns if services should be added immediately.
*/
public boolean isAddImmediately() {
return addImmediately;
}
/**
* @param addImmediately If services should be added immediately.
*/
public void setAddImmediately(boolean addImmediately) {
this.addImmediately = addImmediately;
}
/**
* @return Returns the String to be replaced in the URIs.
*/
public String getReplaceFrom() {
return replaceFrom;
}
/**
* @param replaceFrom The String to be replaced in the URIs.
* @param replaceWith String which will be used instead
*/
public void setReplaceFrom(String replaceFrom,String replaceWith) {
if (!useReplaceWith)
return;
this.replaceFrom = replaceFrom;
this.replaceWith = replaceWith;
}
/**
* @return Returns String which will be used instead.
*/
public String getReplaceWith() {
return replaceWith;
}
/**
* @return Returns if URI substrings should be replaced
*/
public boolean isUseReplaceWith() {
return ( (replaceFrom!=null) && (replaceWith!=null) && useReplaceWith && (!replaceFrom.equals("")) && (!replaceWith.equals("")) ) ;
}
/**
* @param useReplaceWith if URI substrings should be replaced
*/
public void setUseReplaceWith(boolean useReplaceWith) {
this.useReplaceWith = useReplaceWith;
}
public URI replaceString(URI uri) {
//System.out.println("Replacing in URI " + uri.toString());
if (!isUseReplaceWith()) {
return uri;
}
try {
URI testURI;
testURI = new URI (uri.toString().replaceAll(GUIState.getInstance().getReplaceFrom(),
GUIState.getInstance().getReplaceWith()) );
return testURI;
} catch (URISyntaxException e) {
e.printStackTrace();
return uri;
}
}
public void setSorting(int sort) {
this.sorting = sort;
}
public int getSorting() {
return sorting;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -