use of javax.swing.event.InternalFrameEvent in project tetrad by cmu-phil.
the class GeneralizedSemImListEditor method beginNodeEdit.
private void beginNodeEdit(final Node node, final JLabel label, JComponent centering) {
if (launchedEditors.keySet().contains(node)) {
launchedEditors.get(node).moveToFront();
return;
}
final GeneralizedExpressionParameterizer paramEditor = new GeneralizedExpressionParameterizer(semIm, node);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(paramEditor, BorderLayout.CENTER);
panel.setBorder(new EmptyBorder(5, 5, 5, 5));
final EditorWindow editorWindow = new EditorWindow(panel, "Parameter Properties", "OK", true, centering);
DesktopController.getInstance().addEditorWindow(editorWindow, JLayeredPane.PALETTE_LAYER);
editorWindow.pack();
editorWindow.setVisible(true);
launchedEditors.put(node, editorWindow);
editorWindow.addInternalFrameListener(new InternalFrameAdapter() {
public void internalFrameClosing(InternalFrameEvent internalFrameEvent) {
if (!editorWindow.isCanceled()) {
semIm.setSubstitutions(paramEditor.getParameterValues());
// if (node.getNodeType() == NodeType.ERROR) {
// label.setText(node + " = " + semIm.getNodeSubstitutedString(node));
// }
// else {
// label.setText(node + " ~ " + semIm.getNodeSubstitutedString(node));
// }
refreshLabels();
launchedEditors.remove(node);
firePropertyChange("modelChanged", null, null);
}
}
});
}
use of javax.swing.event.InternalFrameEvent in project tetrad by cmu-phil.
the class GeneralizedSemPmGraphicalEditor method beginNodeEdit.
// ========================PRIVATE PROTECTED METHODS======================//
private void beginNodeEdit(final Node node) {
if (launchedEditors.keySet().contains(node)) {
launchedEditors.get(node).moveToFront();
return;
}
final GeneralizedExpressionEditor paramEditor = new GeneralizedExpressionEditor(semPm, node);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(paramEditor, BorderLayout.CENTER);
panel.setBorder(new EmptyBorder(5, 5, 5, 5));
final EditorWindow editorWindow = new EditorWindow(panel, "Edit Expression", "OK", true, this);
DesktopController.getInstance().addEditorWindow(editorWindow, JLayeredPane.PALETTE_LAYER);
editorWindow.pack();
editorWindow.setVisible(true);
launchedEditors.put(node, editorWindow);
editorWindow.addInternalFrameListener(new InternalFrameAdapter() {
public void internalFrameClosing(InternalFrameEvent internalFrameEvent) {
if (!editorWindow.isCanceled()) {
String expressionString = paramEditor.getExpressionString();
try {
semPm.setNodeExpression(node, expressionString);
} catch (ParseException e) {
// This is an expression that's been vetted by the expression editor.
e.printStackTrace();
launchedEditors.remove(node);
throw new RuntimeException("The expression editor returned an unparseable string: " + expressionString, e);
}
refreshLabels();
firePropertyChange("modelChanged", null, null);
}
launchedEditors.remove(node);
}
});
}
use of javax.swing.event.InternalFrameEvent in project tetrad by cmu-phil.
the class GeneralizedSemPmListEditor method beginNodeEdit.
private void beginNodeEdit(final Node node, JComponent centering, final JLabel label) {
if (launchedEditors.keySet().contains(node)) {
launchedEditors.get(node).moveToFront();
return;
}
final GeneralizedExpressionEditor paramEditor = new GeneralizedExpressionEditor(semPm, node);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(paramEditor, BorderLayout.CENTER);
panel.setBorder(new EmptyBorder(5, 5, 5, 5));
final EditorWindow editorWindow = new EditorWindow(panel, "Edit Expression", "OK", true, centering);
DesktopController.getInstance().addEditorWindow(editorWindow, JLayeredPane.PALETTE_LAYER);
editorWindow.pack();
editorWindow.setVisible(true);
launchedEditors.put(node, editorWindow);
editorWindow.addInternalFrameListener(new InternalFrameAdapter() {
public void internalFrameClosing(InternalFrameEvent internalFrameEvent) {
if (!editorWindow.isCanceled()) {
String expressionString = paramEditor.getExpressionString();
try {
semPm.setNodeExpression(node, expressionString);
if (node.getNodeType() == NodeType.ERROR) {
label.setText(node + " = " + semPm().getNodeExpressionString(node));
} else {
label.setText(node + " ~ " + semPm().getNodeExpressionString(node));
}
} catch (ParseException e) {
// This is an expression that's been vetted by the expression editor.
launchedEditors.remove(node);
e.printStackTrace();
throw new RuntimeException("The expression editor returned an unparseable string: " + expressionString, e);
}
paramsEditor.refreshLabels();
firePropertyChange("modelChanged", null, null);
}
launchedEditors.remove(node);
}
});
// GeneralizedExpressionEditor paramEditor = new GeneralizedExpressionEditor(semPm, node);
//
// int ret = JOptionPane.showOptionDialog(centering, paramEditor,
// "Edit Expression", JOptionPane.OK_CANCEL_OPTION,
// JOptionPane.PLAIN_MESSAGE, null, null, null);
//
// if (ret == JOptionPane.OK_OPTION) {
// String expressionString = paramEditor.getExpressionString();
// try {
// semPm.setNodeExpression(node, expressionString);
//
// if (node.getNodeType() == NodeType.ERROR) {
// label.setText(node + " = " + semPm().getNodeExpressionString(node));
// }
// else {
// label.setText(node + " ~ " + semPm().getNodeExpressionString(node));
// }
//
// paramsEditor.freshenDisplay();
// } catch (ParseException e) {
// // This is an expression that's been vetted by the expression editor.
// e.printStackTrace();
// throw new RuntimeException("The expression editor returned an unparseable string: " + expressionString, e);
// }
//
// firePropertyChange("modelChanged", null, null);
// }
}
use of javax.swing.event.InternalFrameEvent in project tetrad by cmu-phil.
the class SessionEditorNode method launchEditorVisit.
private void launchEditorVisit() {
try {
// If there is already an editor open, don't launch another one.
if (spawnedEditor() != null) {
return;
}
boolean created = createModel(false);
if (!created) {
return;
}
final SessionNode sessionNode = getSessionNode();
boolean cloned = sessionNode.useClonedModel();
SessionModel model = sessionNode.getModel();
Class<?> modelClass = model.getClass();
SessionNodeModelConfig modelConfig = this.config.getModelConfig(modelClass);
Object[] arguments = new Object[] { model };
JPanel editor = modelConfig.getEditorInstance(arguments);
addEditorListener(editor);
ModificationRegistery.registerEditor(sessionNode, editor);
String descrip = modelConfig.getName();
editor.setName(getName() + " (" + descrip + ")");
EditorWindow editorWindow = new EditorWindow(editor, editor.getName(), "Done", cloned, this);
editorWindow.addInternalFrameListener(new InternalFrameAdapter() {
@Override
public void internalFrameClosing(InternalFrameEvent e) {
if (getChildren().iterator().hasNext()) {
finishedEditingDialog();
}
ModificationRegistery.unregisterSessionNode(sessionNode);
setSpawnedEditor(null);
EditorWindow window = (EditorWindow) e.getSource();
if (window.isCanceled()) {
sessionNode.restoreOriginalModel();
}
sessionNode.forgetSavedModel();
}
});
DesktopController.getInstance().addEditorWindow(editorWindow, JLayeredPane.PALETTE_LAYER);
editorWindow.pack();
editorWindow.setVisible(true);
spawnedEditor = editorWindow;
if (sessionWrapper != null) {
sessionWrapper.setSessionChanged(true);
}
// for (SessionNode child : getChildren()) {
//
// // only break edges to children.
// if (edge.getNode2() == getModelNode()) {
// SessionNodeWrapper otherWrapper =
// (SessionNodeWrapper) edge.getNode1();
// SessionNode other = otherWrapper.getSessionNode();
// if (getChildren().contains(other)) {
// sessionWrapper.removeEdge(edge);
// }
// } else {
// SessionNodeWrapper otherWrapper =
// (SessionNodeWrapper) edge.getNode2();
// SessionNode other = otherWrapper.getSessionNode();
// if (getChildren().contains(other)) {
// sessionWrapper.removeEdge(edge);
// }
// }
// }
// Class[] consistentModelClasses = child.getConsistentModelClasses(false);
// if (consistentModelClasses.length == 0) {
// child.removeParent(sessionNode);
// SessionEditorWorkbench sessionWorkbench = getSessionWorkbench();
// SessionWrapper sessionWrapper = sessionWorkbench.getSessionWrapper();
// Node node1 = sessionWrapper.getNode(sessionNode.getDisplayName());
// Node node2 = sessionWrapper.getNode(child.getDisplayName());
// Edge edge = sessionWrapper.getEdge(node1, node2);
// sessionWrapper.removeEdge(edge);
// }
} catch (CouldNotCreateModelException e) {
SessionUtils.showPermissibleParentsDialog(e.getModelClass(), SessionEditorNode.this, true, true);
e.printStackTrace();
} catch (ClassCastException e) {
e.printStackTrace();
} catch (Exception e) {
Throwable cause = e;
while (cause.getCause() != null) {
cause = cause.getCause();
}
Component centeringComp = SessionEditorNode.this;
String s = cause.getMessage();
if (!"".equals(s)) {
JOptionPane.showMessageDialog(centeringComp, s, null, JOptionPane.WARNING_MESSAGE);
}
e.printStackTrace();
}
}
use of javax.swing.event.InternalFrameEvent in project browsermator by pcalkins.
the class STAppController method AddMainAppListeners.
public void AddMainAppListeners() {
mainAppFrame.addAboutMenuItemActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
new AboutBox(ProgramVersion);
}
});
mainAppFrame.addExitMenuActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int closure = 0;
int number_of_windows_to_close = 0;
int last_window_index = MDIViewClasses.size() - 1;
for (int x = last_window_index; x > -1; x--) {
closure = CheckToSaveChanges(MDIViewClasses.get(x), MDIDataClasses.get(x), true);
if (closure == 1) {
MDIViewClasses.get(x).setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
} else {
MDIViewClasses.get(x).setDefaultCloseOperation(DISPOSE_ON_CLOSE);
number_of_windows_to_close++;
}
}
if (number_of_windows_to_close == MDIViewClasses.size()) {
for (int x = 0; x < number_of_windows_to_close; x++) {
MDIViewClasses.remove(MDIViewClasses.size() - 1);
MDIDataClasses.remove(MDIDataClasses.size() - 1);
}
}
if (MDIViewClasses.size() == 0) {
Properties newProps = new Properties();
Boolean file_exists = false;
try {
File f = new File(BrowsermatorAppFolder + "browsermator_config.properties");
FileInputStream input = new FileInputStream(BrowsermatorAppFolder + "browsermator_config.properties");
newProps.load(input);
newProps.setProperty("main_window_locationY", Integer.toString(mainAppFrame.getY()));
newProps.setProperty("main_window_locationX", Integer.toString(mainAppFrame.getX()));
newProps.setProperty("main_window_sizeWidth", Integer.toString(mainAppFrame.getWidth()));
newProps.setProperty("main_window_sizeHeight", Integer.toString(mainAppFrame.getHeight()));
FileWriter writer = new FileWriter(BrowsermatorAppFolder + "browsermator_config.properties");
newProps.store(writer, "browsermator_settings");
writer.close();
} catch (Exception e) {
System.out.println("Exception: " + e);
}
System.exit(0);
}
}
});
mainAppFrame.addFileMenuImportActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
CurrentMDIWindowIndex = GetCurrentWindow();
if (CurrentMDIWindowIndex != -1) {
File[] newfiles = BrowseForFile();
if (newfiles != null) {
ImportFileFunct(newfiles, CurrentMDIWindowIndex);
}
} else {
JOptionPane.showMessageDialog(null, "No Active Window to import into. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
}
}
});
mainAppFrame.addFileMenuSaveActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
CurrentMDIWindowIndex = GetCurrentWindow();
if (CurrentMDIWindowIndex != -1) {
SeleniumTestToolData STAppData = MDIDataClasses.get(CurrentMDIWindowIndex);
SeleniumTestTool STAppFrame = MDIViewClasses.get(CurrentMDIWindowIndex);
ThreadSaveFile(mainAppFrame, STAppFrame, STAppData, false, false);
} else {
JOptionPane.showMessageDialog(null, "No Active Window to save. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
}
}
});
mainAppFrame.addFileMenuCloseActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
CurrentMDIWindowIndex = GetCurrentWindow();
if (CurrentMDIWindowIndex != -1) {
SeleniumTestTool STAppFrame = MDIViewClasses.get(CurrentMDIWindowIndex);
SeleniumTestToolData STAppData = MDIDataClasses.get(CurrentMDIWindowIndex);
int closed = CheckToSaveChanges(STAppFrame, STAppData, false);
if (closed == 1) {
STAppFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
} else {
// RemoveWindow(MDIClasses.size()-1);
int thisMDIIndex = GetCurrentWindow();
RemoveWindow(thisMDIIndex);
STAppFrame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
STAppFrame.dispose();
}
} else {
JOptionPane.showMessageDialog(null, "No Active Window to close. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
}
}
});
mainAppFrame.addFileMenuBrowseCloudMenuItemActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
OpenBrowserMatorCloud();
}
});
mainAppFrame.addFileMenuuploadFileToCloudMenuItemActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
CurrentMDIWindowIndex = GetCurrentWindow();
if (CurrentMDIWindowIndex != -1) {
SeleniumTestTool STAppFrame = MDIViewClasses.get(CurrentMDIWindowIndex);
SeleniumTestToolData STAppData = MDIDataClasses.get(CurrentMDIWindowIndex);
UploadFile(STAppFrame, STAppData, true, false);
} else {
JOptionPane.showMessageDialog(null, "No Active Window to save. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
}
}
});
mainAppFrame.addFileMenuSaveAsActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
CurrentMDIWindowIndex = GetCurrentWindow();
if (CurrentMDIWindowIndex != -1) {
SeleniumTestToolData STAppData = MDIDataClasses.get(CurrentMDIWindowIndex);
SeleniumTestTool STAppFrame = MDIViewClasses.get(CurrentMDIWindowIndex);
ThreadSaveFile(mainAppFrame, STAppFrame, STAppData, true, false);
} else {
JOptionPane.showMessageDialog(null, "No Active Window to save. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
}
}
});
mainAppFrame.addFileMenuNewActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String filename = "";
if (MDIViewClasses.size() == 0) {
filename = "untitled";
} else {
filename = "untitled" + MDIViewClasses.size();
}
ArrayList<ProcedureView> blankprocviews = new ArrayList<ProcedureView>();
ArrayList<Procedure> blankprocs = new ArrayList<Procedure>();
SeleniumTestToolData STAppData = new SeleniumTestToolData(blankprocs);
STAppData.setFilenames(filename);
STAppData.setTargetBrowser("Chrome");
STAppData.setTargetBrowser("Chrome");
STAppData.setOSType("Windows32");
STAppData.setIsTemplateOrNew(true);
SeleniumTestTool STAppFrame = new SeleniumTestTool(STAppData);
STAppFrame.setFilename(filename);
STAppFrame.ShowStoredVarControls(false);
STAppFrame.setClosable(true);
STAppFrame.setMaximizable(true);
STAppFrame.setResizable(true);
MDIViewClasses.add(STAppFrame);
MDIDataClasses.add(STAppData);
DisplayWindow(MDIViewClasses.size() - 1);
STAppFrame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() {
@Override
public void internalFrameClosing(InternalFrameEvent e) {
int closed = CheckToSaveChanges(STAppFrame, STAppData, false);
if (closed == 1) {
STAppFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
} else {
int thisMDIIndex = GetCurrentWindow();
RemoveWindow(thisMDIIndex);
// RemoveWindow(MDIClasses.size()-1);
STAppFrame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
}
});
STAppFrame.addjButtonDoStuffActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
RunActions(STAppFrame, STAppData);
}
});
STAppFrame.addjButtonClearEmailSettingsListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
STAppFrame.ClearEmailSettings();
STAppData.ClearEmailSettings();
}
});
STAppFrame.addjButtonLoadEmailSettingsListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
STAppData.loadGlobalEmailSettings();
STAppFrame.setEmailSettings(STAppData);
} catch (Exception ex) {
System.out.println("Exception loading global email settings: " + ex.toString());
}
}
});
STAppFrame.addTargetBrowserItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if ((e.getStateChange() == ItemEvent.SELECTED)) {
Object ActionType = e.getItem();
String TargetBrowser = ActionType.toString();
STAppFrame.setTargetBrowserView(TargetBrowser);
STAppData.changes = true;
}
}
});
STAppFrame.addjButtonGutsViewActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
showGuts(STAppFrame, STAppData);
}
});
STAppFrame.addjButtonNewBugActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
STAppFrame.saveState();
int insertionPoint = STAppFrame.getInsertionPoint();
STAppData.AddNewBug(insertionPoint);
STAppFrame.AddNewBugView(insertionPoint);
int last_added_bug_index = insertionPoint - 1;
ProcedureView newbugview = STAppFrame.BugViewArray.get(last_added_bug_index);
Procedure newbug = STAppData.BugArray.get(last_added_bug_index);
AddNewHandlers(STAppFrame, STAppData, newbugview, newbug);
STAppFrame.UpdateDisplay();
JScrollBar vertical = STAppFrame.MainScrollPane.getVerticalScrollBar();
vertical.setValue(vertical.getMaximum());
}
});
STAppFrame.addjButtonNewDataLoopActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
STAppFrame.saveState();
int insertionPoint = STAppFrame.getInsertionPoint();
STAppData.AddNewDataLoop(insertionPoint);
STAppFrame.AddNewDataLoopView(insertionPoint);
int last_added_bug_index = insertionPoint - 1;
ProcedureView newbugview = STAppFrame.BugViewArray.get(last_added_bug_index);
Procedure newbug = STAppData.BugArray.get(last_added_bug_index);
AddNewHandlers(STAppFrame, STAppData, newbugview, newbug);
AddLoopHandlers(STAppFrame, STAppData, newbugview, newbug);
STAppFrame.UpdateDisplay();
JScrollBar vertical = STAppFrame.MainScrollPane.getVerticalScrollBar();
vertical.setValue(vertical.getMaximum());
}
});
}
});
mainAppFrame.addFileMenuOpenActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
File[] newfiles = BrowseForFile();
if (newfiles != null) {
for (int fileindex = 0; fileindex < newfiles.length; fileindex++) {
OpenFile(newfiles[fileindex], false);
}
}
}
});
}
Aggregations