rendered paste bodypackage katastrofeklient;
import javax.swing.*;
import katastrofeserver.*;
import java.awt.*;
import java.util.*;
public class WarpQuestion extends JDialog {
private Main main;
private GUI gui;
private Object returnValue;
public WarpQuestion(Main main, GUI gui){
super(gui, true);
this.main = main;
this.gui = gui;
this.setLayout(new BorderLayout());
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public Behov hentBehov() {
searchFor("behov");
return (Behov)returnValue;
}
public Observasjon hentObservasjon() {
searchFor("observasjon");
return (Observasjon)returnValue;
}
public Person hentPerson() {
searchFor("personer");
return (Person)returnValue;
}
public Ressurs hentRessurs() {
searchFor("ressurser");
return (Ressurs)returnValue;
}
private void searchFor(String searchString) {
Container cp = getContentPane();
this.setLocation(gui.getX() + 100, gui.getY() + 100);
this.setSize(gui.getSize().width - 200, gui.getSize().height - 200);
for (Component c : cp.getComponents()) {
if (c instanceof WarpTable) {
cp.remove(c);
}
}
String sok = "SOEK;;;" + searchString;
Object svar = main.sendObject(sok);
cp.add(new WarpTable(this, (ArrayList) svar, WarpTable.SELECTBUTTONS,
main),
BorderLayout.CENTER);
this.validate();
this.setVisible(true);
}
public void setReturnValue(Object o) {
returnValue = o;
}
}