📄 casewindow.java
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
*
* $Author$
* $Date$
* $Revision$
*
*/
package eti.bi.alphaminer.ui;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyVetoException;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.WindowConstants;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
import javax.swing.plaf.basic.BasicToolBarUI;
import eti.bi.alphaminer.core.handler.CaseHandler;
import eti.bi.alphaminer.core.handler.ICaseHandler;
import eti.bi.alphaminer.core.observer.HelpObserveSubject;
import eti.bi.alphaminer.core.observer.HelpObserver;
import eti.bi.alphaminer.core.observer.ObserveSubject;
import eti.bi.alphaminer.core.observer.Observer;
import eti.bi.alphaminer.jhelpcomponent.HelpCursor;
import eti.bi.alphaminer.jhelpcomponent.JHelpSplitPane;
import eti.bi.alphaminer.jhelpcomponent.JHelpTabbedPane;
import eti.bi.alphaminer.jhelpcomponent.JHelpToolBar;
import eti.bi.alphaminer.operation.operator.Operator;
import eti.bi.alphaminer.patch.standard.operation.operator.InsightOperator;
import eti.bi.alphaminer.tools.SystemTools.CaseHelpToolBarHandler;
import eti.bi.alphaminer.tools.SystemTools.SystemHelpToolBarContainer;
import eti.bi.exception.BaseException;
import eti.bi.exception.SysException;
import eti.bi.util.ResourceLoader;
import eti.bi.common.ImageLocation;
import eti.bi.common.Locale.Resource;
import eti.bi.common.System.SysLog;
//import eti.bi.alphaminer.ui.FloatMenu;
/**
* CaseWindow is a class of the case window user interface (UI).
*/
public class CaseWindow extends JInternalFrame implements
Observer,
HelpObserver,
ObserveSubject,
SystemHelpToolBarContainer,
InternalFrameListener,
MouseListener,
MouseMotionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
// private OperatorPanel m_OperatorPanel;
//private SystemMessagePanel m_SystemMessagePanel;
private DescriptionPanel m_DescriptionPanel;
private CaseDiagramPanel m_CaseDiagramPanel;
// private JSplitPane m_SplitPaneDiagramMessage;
private JHelpSplitPane m_SplitPaneDiagramMessage; // <<25/07/2005: Kenneth Lai: Add for JHelp>>
private JHelpTabbedPane m_MessageTab;
//SystemCaseToobar
private JHelpToolBar m_CaseToolBar;
private CaseHelpToolBarHandler m_CaseHelpToolBarHandler;
private ApplicationWindow m_ParentFrame;
private boolean m_IsEditMode;
private boolean m_HelpState;// <<25/07/2005: Kenneth Lai: Add for JHelp>>
private String m_CaseID;
private String m_CaseName;//<<Mark Li,22/02/2005 Add Case Name
private boolean m_IsModified;
private boolean m_IsNew;
private int m_DMEngineType; //<<Frank Xu, 09/12/2004 flag to differentiate the type of data mining engines., Frank Xu, 09/12/2004>>.
private ICaseHandler m_CaseHandler;
private ISystemMessageHandler m_SystemMessageHandler;
private IMessageDialog m_MessageDialog;
/**
* Constructs a CaseWindow.
* @param a_Frame ApplicationWindow to which this CaseWindow resides.
* @param a_IsEdit indicates the mode of this CaseWindow. True if it is opened
* in edit mode; false if it is opened in view mode.
*/
/* public CaseWindow(ApplicationWindow a_Frame, boolean a_IsEdit) {
m_ParentFrame = a_Frame;
m_IsModified = false;
m_IsEditMode = a_IsEdit;
m_DMEngineType = OperatorPanelFactory.ETI_DM;
createCaseWindow();
}
*/
/**
* Constructs a CaseWindow.
* @param a_Frame ApplicationWindow to which this CaseWindow resides.
* @param a_IsNew true if the Case represented by this CaseWindow is a newly
* created Case; false otherwise.
* @param a_CaseID ID of the Case this CaseWindow is showing.
* @param a_IsEdit indicates the mode of this CaseWindow. True if it is opened
* in edit mode; false if it is opened in view mode.
*/
public CaseWindow(
ApplicationWindow a_Frame,
boolean a_IsNew,
String a_CaseID,
boolean a_IsEdit,
int a_DMEngineType) {
//this(a_Frame, a_IsEdit);
m_CaseHandler = CaseHandler.getInstance();
m_MessageDialog = m_CaseHandler.getMessageDialog();
try {
m_IsNew = a_IsNew;
if (a_IsNew) {
m_IsModified = true;
if (a_CaseID == null)
{
//<<01/04/2005, Frank J. Xu
setCaseID(CaseHandler.getInstance().createCase());
setCaseName("Untitled-", a_Frame.getNewCaseIndex(), true);//22/02/2005 Mark Li: Add setCaseName();
//01/04/2005, Frank J. Xu>>
}
else {
setCaseID(CaseHandler.getInstance().copyCase(a_CaseID));
//setCaseName(CaseHandler.getInstance().getCase(a_CaseID,false).getTaskNode().getCaseName(), a_Frame.getNewCaseIndex(), true);//22/02/2005 Mark Li: Add setCaseName();
setCaseName("Untitled-", a_Frame.getNewCaseIndex(), true);
}
m_SystemMessageHandler = m_CaseHandler.getSystemMessageHandler(m_CaseID);
} else {
setCaseID(a_CaseID);
m_SystemMessageHandler = m_CaseHandler.getSystemMessageHandler(m_CaseID);
//<<21/02/2005 Mark Li: Add Case Name
setCaseName(CaseHandler.getInstance().getCase(a_CaseID,false).getTaskNode().getCaseName(), a_Frame.getNewCaseIndex(), false);//22/02/2005 Mark Li: Add setCaseName();
setTitle(m_CaseName);
//21/02/2005 Mark Li: Add Case Name>>
//<<11/03/2005 Mark Li:Show warning messages pop up when closing a new created/copyed case.
m_IsModified = false;
//11/03/2005 Mark Li:Show warning messages pop up when closing a new created/copyed case.>>
}
m_ParentFrame = a_Frame;
//<<11/03/2005 Mark Li:Show warning messages pop up when closing a new created/copyed case.
//m_IsModified = false;
//11/03/2005 Mark Li:Show warning messages pop up when closing a new created/copyed case.>>
m_IsEditMode = a_IsEdit;
m_DMEngineType = a_DMEngineType;
createCaseWindow();
m_CaseDiagramPanel.drawCaseDiagram();
} catch (BaseException be) {
System.err.println(be.getMessage());
SysLog.error(null,be);
}
m_SystemMessageHandler = m_CaseHandler.getSystemMessageHandler(m_CaseID);
setHelpMode(false); //default
}
/**
* Sets mode of this CaseWindow.
* @param m_IsEdit true to set it in edit mode;
* false to set it in view mode.
*/
public void setEditMode(boolean a_IsEdit) {
if (m_IsEditMode == a_IsEdit)
return;
//System.out.println("change to view: (modified) " + m_IsModified);
if (!a_IsEdit && m_IsModified) {
int option =
JOptionPane.showConfirmDialog(
(Component) this,
Resource.srcStr("SaveChanges") + this.getTitle() + "\"",
Resource.srcStr("AlphaMiner"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (option != JOptionPane.CANCEL_OPTION) {
if (option == JOptionPane.YES_OPTION)
save();
else {
try {
CaseHandler.getInstance().getCase(m_CaseID, true);
} catch (BaseException be) {
System.err.println(be.getMessage());
}
m_CaseDiagramPanel.clearCaseDiagram();
try {
m_CaseDiagramPanel.drawCaseDiagram();
} catch (SysException e) {
m_MessageDialog.showError(e.getMessage(),"Error");
}
setModified(false);
}
}
}
m_IsEditMode = a_IsEdit;
setEditModeLayout();
notifyParent();
}
/**
* Get current mode if CaseWindow.
* @return true if it is currently in edit mode; false otherwise.
*/
public boolean getEditMode() {
return m_IsEditMode;
}
/**
* Gets the SystemMessagePanel.
* @return JPanel the SystemMessagePanel.
*/
public DescriptionPanel getDescriptionPanel() {
return m_DescriptionPanel;
}
/**
* Gets the DiagramDrawingPanel.
* @return JPanel the DiagramDrawingPanel.
*/
public JPanel getDiagramDrawingPanel() {
return m_CaseDiagramPanel;
}
/**
* Sets title of CaseWindow.
* @param a_Name title to be set.
*/
public void setCaseWindowTitle(String a_Name) {
this.setTitle(a_Name);
}
/**
* Sets floating state of the OperatorPanel.
* @param a_IsFloat true to make it float; false to dock it
* into the CaseWindow.
*/
/*
public void setOperatorPanelFloat(boolean a_IsFloat) {
if (a_IsFloat)
floatOperatorPanel();
else
dockOperatorPanel();
}
/**
* Flosts OperatorPanel, separates it from CaseWindow.
*/
/*
public void floatOperatorPanel()
{
//m_OperatorToolBar.setFloatable(true);
((BasicToolBarUI) m_OperatorToolBar.getUI()).setFloating(
true,
new Point(0, 0));
((Window) m_OperatorToolBar.getTopLevelAncestor()).setAlwaysOnTop(true);
(
(Window) m_OperatorToolBar
.getTopLevelAncestor())
.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
m_FloatMenu.setIsFloat(false);
}
});
//m_OperatorToolBar.setFloatable(false);
}
*/
/**
* Docks OperatorPanel, append it into the CaseWindow.
*/
/*
public void dockOperatorPanel() {
//m_OperatorToolBar.setFloatable(true);
((BasicToolBarUI) m_OperatorToolBar.getUI()).setFloating(false, null);
getContentPane().add(m_OperatorToolBar, BorderLayout.WEST);
//m_OperatorToolBar.setFloatable(false);
}
*/
/**
* Deletes the Case represented by this CaseWindow.
* @return true if user confirms to delete it; false if user cancel the
* deletion.
*/
public boolean delete() {
int option =
JOptionPane.showConfirmDialog(
(Component) this,
"Delete \"" + this.getTitle() + "\"?",
Resource.srcStr("AlphaMiner"),
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (option == JOptionPane.YES_OPTION) {
// delete
try
{
CaseHandler.getInstance().removeCase(getCaseID());
} catch (Exception e)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -