/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.appogcecl.actioncontroller;
import gov.nasa.worldwind.geom.Position;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.InvalidClassException;
import java.io.NotSerializableException;
import java.io.WriteAbortedException;
import java.util.*;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
import org.geoforge.appogcecl.GfrAppSpcOgcAbs;
import org.geoforge.appogcecl.actionmanager.GfrAmrAppPrsRunAbs;
import org.geoforge.appogcecl.handler.IHandlerLoaderSecondaryWindowsProject;
import org.geoforge.appogcecl.util.hashset.GfrHstFrmIntViewersPrsRun;
import org.geoforge.guihlp.handler.IGfrHandlerSetEnabledTrueHelpOnThisSection;
import org.geoforge.guillc.GfrAppSpcAbs;
import org.geoforge.guillc.action.*;
import org.geoforge.guillc.button.BtnAbs;
import org.geoforge.guillc.desktoppane.GfrDpnWinViewerMainPrcAbs;
import org.geoforge.guillc.dialog.*;
import org.geoforge.guillc.frame.GfrFrmAbs;
import org.geoforge.guillc.internalframe.*;
import org.geoforge.guillc.io.serial.GfrSerializeFrameSecViewerIntApp;
import org.geoforge.guillc.io.serial.GfrSerializeFrameSecViewerIntPlg;
import org.geoforge.guillc.menuitem.*;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.GfrPnlStatusBarMain;
import org.geoforge.io.serial.GfrSerializeStateWwdSec;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.lang.thread.GfrThr;
import org.geoforge.lang.util.GfrResBundleLang;
import org.geoforge.mdldsp.event.frame.GfrEvtMdlDspAddedIfrRun;
import org.geoforge.mdldsp.event.state.singleton.selecttlo.GfrEvtMdlSttSngSelTlo;
import org.geoforge.mdldsp.frame.GfrMdlDspIfrRunAny;
import org.geoforge.mdldsp.state.singleton.selecttlo.GfrMdlSttSngSelTlo;
import org.geoforge.wrpbasprsdsp.selection.lastspace.GfrWrpDspLastSpaceProject;
import org.geoforge.wrpbasprsdsp.viewer.GfrWrpBasPrsDspPrjViewersExisting;
import org.geoforge.wrpbasprsdsp.viewer.GfrWrpDspSynViewer;
/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*
*/
abstract public class GfrAcrSpcAppPrsPrjRunAbs extends GfrAcrSpcAppPrsPrjAbs implements
InternalFrameListener,
Observer
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(GfrAcrSpcAppPrsPrjRunAbs.class.getName());
static
{
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
abstract public void tileViewersInternal() throws Exception;
abstract public void tileHorizontallyViewersInternal() throws Exception;
abstract public void tileVerticallyViewersInternal() throws Exception;
abstract public void cascadeViewersInternal() throws Exception;
abstract public void newChildViewerInternalTopsWwdEarthHandler() throws Exception;
abstract public void newChildViewerInternalTopsJfcChartHandler() throws Exception;
abstract public void newChildViewerInternalTopsImgLgdLyrWmsHandler() throws Exception;
abstract protected void _windowViewerInternalTopsWwdEarthHandler(Position pos, double dblZoom) throws Exception;
abstract protected void _windowViewerInternalTopsJcfChartHandler(String strIdTlo) throws Exception;
abstract public void moveObjectsWwdEarthHandler(String strIdViewerSource)throws Exception;
protected ActionListener _alrProject = null; // used in sec windows
protected GfrAcrSpcAppPrsPrjRunAbs(
GfrAppSpcAbs app,
GfrAmrAppPrsRunAbs amr,
ActionListener alrController)
throws Exception
{
super(app,
amr,
GfrResBundleLang.s_getInstance().getValue("verb.run").toLowerCase());
this._alrProject = alrController;
GfrMdlSttSngSelTlo.getInstance().addObserver((Observer) this);
GfrMdlDspIfrRunAny.s_getInstance().addObserver((Observer) this);
}
protected void _loadSerializedViewersInternal() throws Exception
{
this._loadViewersInternalPlugin_();
}
protected void _loadInternalFinalize(GfrDpnWinViewerMainPrcAbs dpn) throws Exception
{
for (GfrIfrWinViewRunAbs frmCur: GfrHstFrmIntViewersPrsRun.s_getInstance().get())
{
if (!(frmCur instanceof GfrIfrWinViewRunIdRegSerAbs)) // should never appear
continue;
((GfrIfrWinViewRunIdRegSerAbs) frmCur).loadUnserializedObject();
frmCur.pack();
frmCur.setVisible(true);
dpn.add(frmCur, new Integer(1));
}
if (GfrHstFrmIntViewersPrsRun.s_getInstance().size() > 0)
dpn.validate(); // if any ifr !!!
// ---
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
if (GfrHstFrmIntViewersPrsRun.s_getInstance().size() < 1)
return;
for (GfrIfrWinViewRunAbs frmCur: GfrHstFrmIntViewersPrsRun.s_getInstance().get())
{
if (! (frmCur instanceof IGfrHandlerSetEnabledTrueHelpOnThisSection))
continue;
((IGfrHandlerSetEnabledTrueHelpOnThisSection) frmCur).setEnabledTrueHelpOnThisSection(
((GfrAppSpcOgcAbs) _app).getHelpBroker());
}
}
});
//_setEnabledActionsViewersInternal(true); // !!! if nothing ???
boolean blnNoViewer = GfrHstFrmIntViewersPrsRun.s_getInstance().get().isEmpty();
_setEnabledActionsOnExistingInternalViewers_(!blnNoViewer); // TEMPO, should send event to model somewhere (already exists)
}
@Override
public void update(Observable obs, Object objEvt)
{
try
{
if (objEvt instanceof GfrEvtMdlDspAddedIfrRun)
{
_setEnabledActionsOnExistingInternalViewers_(true);
return;
}
if (obs instanceof GfrMdlSttSngSelTlo)
{
GfrEvtMdlSttSngSelTlo evt = (GfrEvtMdlSttSngSelTlo) objEvt;
if (evt.getValue() == true)
return;
String strIdTlo = evt.getKey();
this.deleteWindowTloIfAny(strIdTlo);
return;
}
if (obs instanceof GfrMdlDspIfrRunAny)
{
// MEMO: this one should replace actionListener and internalFrameListenr while closing/destroying internal frame
// !!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// ATTN: be carefull with serialized internalFrames v/s model
return;
}
// uncaught
String strError = "Dev coding error, uncaught obs: " + obs.getClass().toString();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(strError);
GfrOptionPaneAbs.s_showDialogError(null, strError);
}
catch(Exception exc)
{
exc.printStackTrace();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(exc.getMessage());
GfrOptionPaneAbs.s_showDialogError(null, exc.getMessage());
}
}
private void _setEnabledActionsOnExistingInternalViewers_(boolean bln)
{
GfrActDlgLloCloseAllWindowsInternal.s_getInstance().setEnabled(bln);
GfrActDlgLloTileWindowsInternal.s_getInstance().setEnabled(bln);
GfrActDlgLloTileHorizWindowsInternal.s_getInstance().setEnabled(bln);
GfrActDlgLloTileVertWindowsInternal.s_getInstance().setEnabled(bln);
GfrActDlgLloCascadeWindowsInternal.s_getInstance().setEnabled(bln);
}
@Override
public void preferencesAppliHandler()
{
try
{
DlgAbs dlg = new GfrDlgTabsPrefsPrsRun();
if (!dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
throw new Exception(str);
}
dlg.setVisible(true);
}
catch(Exception exc)
{
exc.printStackTrace();
String str = exc.getMessage();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
return;
}
}
// !!! _setEnabledActionsWindowsInternal(bln); !!!
/*private void _setEnabledActionsViewersInternal_(boolean bln)
{
// SHOULD BE RELATED TO NEW viewer GfrActDlgLloCloseAllWindowsInternal.s_getInstance().setEnabled(bln);
// TODO/ tile, cascade
if (! bln)
{
_setEnabledActionsOnExistingInternalViewers_(bln); // false
}
else
{
// TODO: if any viewers
if (GfrHstFrmIntViewersPrsRun.s_getInstance().size() > 0)
{
_setEnabledActionsOnExistingInternalViewers_(bln); // true
}
}
}*/
/*
* TODO: instantiate internalFrames classes in JAR files
* MEMO: JarClassLoader
* <dependency>
<groupId>org.xeustechnologies</groupId>
<artifactId>jcl-core</artifactId>
<version>2.3</version>
</dependency>
*
*/
/*
private void _instantiateInternalFramesPluginClassesInJars_() throws Exception
{
String[] strsNameFile = GfrWrpUsrSpcDspPrtRoot.getInstance().getListNameFilePlugins();
if (strsNameFile==null || strsNameFile.length<1)
{
// we are in trouble!
// rather remove all those serialized files
AcrPrsRunAbs._LOGGER_.warning("strsNameFile==null || strsNameFile.length<1");
return;
}
String strPathAbsFolderJars = System.getProperty(GfrEnuSystemPropertiesKeys.PATH_PLUGINS_APPLI.getLabel());
File fleFolderJars = new File(strPathAbsFolderJars);
if (! fleFolderJars.exists())
{
// we are in trouble!
// rather remove all those serialized files
AcrPrsRunAbs._LOGGER_.warning("! fleFolderJars.exists(): " + fleFolderJars.getAbsolutePath());
return;
}
if (! fleFolderJars.isDirectory())
{
// we are in serious trouble, Houston ...
// rather remove all those serialized files
AcrPrsRunAbs._LOGGER_.warning("! fleFolderJars.isDirectory(): " + fleFolderJars.getAbsolutePath());
return;
}
for (int i=0; i<strsNameFile.length; i++)
{
String[] strsNameClass = GfrWrpUsrSpcDspPrtRoot.getInstance().getListNameClassPlugin(strsNameFile[i]);
if (strsNameClass==null || strsNameClass.length<1)
{
continue;
}
File fleCurJar = new File(fleFolderJars, strsNameFile[i]);
if (! fleCurJar.exists())
{
AcrPrsRunAbs._LOGGER_.warning("! fleCurJar.exists(): " + fleCurJar.getAbsolutePath());
continue;
}
if (! fleCurJar.isFile())
{
// troubleshootings !!!
AcrPrsRunAbs._LOGGER_.severe("! fleCurJar.isFile(): " + fleCurJar.getAbsolutePath());
continue;
}
//we got the JAR
for (int j=0; j<strsNameClass.length; j++)
{
Class clsCur = null;
try
{
clsCur = Class.forName(strsNameClass[j]);
}
catch(Exception exc)
{
// TODO: load from JAR
exc.printStackTrace();
AcrPrsRunAbs._LOGGER_.warning("TODO: load Object, strsNameClass[j]=" + strsNameClass[j]);
try
{
JarClassLoader jcl = new JarClassLoader();
jcl.add(new FileInputStream(fleCurJar));
JclObjectFactory factory = JclObjectFactory.getInstance();
//Create object of loaded class
Object obj = factory.create(jcl, strsNameClass[j]);
String str = obj.getClass().getName();
System.out.println("before str=" + str);
clsCur = Class.forName(strsNameClass[j]);
System.out.println("after str=" + str);
}
catch(Exception exc2)
{
exc2.printStackTrace();
// !!! logger and dialog !!!
continue;
}
}
}
}
}
*/
private HashSet<GfrIfrWinViewRunIdRegSerAbs> _loadViewersInternalPlugin_(ArrayList<String> alrPathsAbs) throws Exception
{
HashSet<GfrIfrWinViewRunIdRegSerAbs> hst = new HashSet<GfrIfrWinViewRunIdRegSerAbs>();
if (alrPathsAbs==null || alrPathsAbs.isEmpty())
return hst;
// ---
//_instantiateInternalFramesPluginClassesInJars_();
// ---
for (int i = 0; i < alrPathsAbs.size(); i++)
{
String strPathAbsCur = alrPathsAbs.get(i);
GfrIfrWinViewRunIdRegSerAbs ifr = null;
try
{
ifr = (GfrIfrWinViewRunIdRegSerAbs) GfrSerializeFrameSecViewerIntPlg.s_getInstance().read(strPathAbsCur);
}
/*
* TODO: remove file in case of Exception
*
* TBRL with File.deleteOnExit()
* WRND: TODO: store absPath in DB, then at relaunch, deleteFile at first, then remove absPath from DB
* IMPORETANT:
* . xxx.jframe.ser
* xxx.recBounds.ser
*/
catch(WriteAbortedException excWriteAborted) // !!!!!
{
excWriteAborted.printStackTrace();
String str = "Got WriteAbortedException";
str += "\n strPathAbsCur=" + strPathAbsCur;
str += "\n\n don't care"; // TODO: fix this up
File fle = new File(strPathAbsCur);
if (fle.exists())
{
str += ", deleting on exit";
fle.deleteOnExit(); // NOT WORKING!!!
}
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.warning(str);
continue;
}
catch (NotSerializableException excNotSerializable)
{
excNotSerializable.printStackTrace();
String str = "Got NotSerializableException";
str += "\n strPathAbsCur=" + strPathAbsCur;
str += "\n\n don't care"; // TODO: fix this up
File fle = new File(strPathAbsCur);
if (fle.exists())
{
str += ", deleting on exit";
fle.deleteOnExit(); // NOT WORKING!!!
}
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.warning(str);
continue;
}
catch (Exception exc)
{
exc.printStackTrace();
String str = "Got Exception";
str += "\n strPathAbsCur=" + strPathAbsCur;
str += "\n\n don't care"; // TODO: fix this up
File fle = new File(strPathAbsCur);
if (fle.exists())
{
str += ", deleting on exit";
fle.deleteOnExit(); // NOT WORKING!!!
}
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.warning(str);
continue;
}
GfrHstFrmIntViewersPrsRun.s_getInstance().add(ifr);
hst.add(ifr);
}
return hst;
}
private HashSet<GfrIfrWinViewRunIdRegSerAbs> _loadViewersInternalApplication_(ArrayList<String> alrs) throws Exception
{
HashSet<GfrIfrWinViewRunIdRegSerAbs> hst = new HashSet<GfrIfrWinViewRunIdRegSerAbs>();
for (int i = 0; i < alrs.size(); i++)
{
String strPathAbsCur = alrs.get(i);
GfrIfrWinViewRunIdRegSerAbs ifr = null;
try
{
ifr = (GfrIfrWinViewRunIdRegSerAbs) GfrSerializeFrameSecViewerIntApp.s_getInstance().read(strPathAbsCur);
}
/*
* TODO: remove file in case of Exception
*
* TBRL with File.deleteOnExit()
* WRND: TODO: store absPath in DB, then at relaunch, deleteFile at first, then remove absPath from DB
* IMPORETANT:
* . xxx.jframe.ser
* xxx.recBounds.ser
*/
catch(WriteAbortedException excWriteAborted) // !!!!!
{
excWriteAborted.printStackTrace();
String str = "Got WriteAbortedException";
str += "\n strPathAbsCur=" + strPathAbsCur;
str += "\n\n don't care"; // TODO: fix this up
File fle = new File(strPathAbsCur);
if (fle.exists())
{
str += ", deleting on exit";
fle.deleteOnExit(); // NOT WORKING!!!
}
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.warning(str);
continue;
}
catch (NotSerializableException excNotSerializable)
{
excNotSerializable.printStackTrace();
String str = "Got NotSerializableException";
str += "\n strPathAbsCur=" + strPathAbsCur;
str += "\n\n don't care"; // TODO: fix this up
File fle = new File(strPathAbsCur);
if (fle.exists())
{
str += ", deleting on exit";
fle.deleteOnExit(); // NOT WORKING!!!
}
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.warning(str);
continue;
}
catch(InvalidClassException excInvalidClass) // !!!!!!!! never caught !!!!!!!!!
{
excInvalidClass.printStackTrace();
String str = "Got InvalidClassException";
str += "\n strPathAbsCur=" + strPathAbsCur;
str += "\n\n don't care"; // TODO: fix this up
File fle = new File(strPathAbsCur);
if (fle.exists())
{
str += ", deleting on exit";
fle.deleteOnExit(); // NOT WORKING!!!
}
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.warning(str);
continue;
}
catch (Exception exc)
{
exc.printStackTrace();
String str = "Got Exception";
str += "\n strPathAbsCur=" + strPathAbsCur;
str += "\n\n don't care"; // TODO: fix this up
File fle = new File(strPathAbsCur);
if (fle.exists())
{
str += ", deleting on exit";
fle.deleteOnExit(); // NOT WORKING!!!
}
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.warning(str);
continue;
}
GfrHstFrmIntViewersPrsRun.s_getInstance().add(ifr);
hst.add(ifr);
}
return hst;
}
/*
* v/s applications
*/
private void _loadViewersInternalPlugin_() throws Exception
{
ArrayList<String> alrs = GfrSerializeFrameSecViewerIntPlg.s_getInstance().getPathsAbsolute();
HashSet<GfrIfrWinViewRunIdRegSerAbs> hst = this._loadViewersInternalPlugin_(alrs);
for (GfrIfrWinViewRunIdRegSerAbs ifrCur: hst)
{
ifrCur.addActionListenerPerspectiveRun((ActionListener) AcrPlgIfrRun.getInstance()); // !!!
ifrCur.addInternalFrameListener((InternalFrameListener) AcrPlgIfrRun.getInstance());
}
}
/*
* v/s plugins
*/
protected void _loadViewersInternalApplication(String strNameClassFrame) throws Exception
{
ArrayList<String> alrs = GfrSerializeFrameSecViewerIntApp.s_getInstance().getPathsAbsolute(strNameClassFrame);
HashSet<GfrIfrWinViewRunIdRegSerAbs> hst = this._loadViewersInternalApplication_(alrs);
for (GfrIfrWinViewRunIdRegSerAbs ifrCur: hst)
{
ifrCur.addActionListenerPerspectiveRun((ActionListener) this); // !!!
((GfrIfrWinViewRunIdRegSerAppAbs) ifrCur).setActionListenerControllers(this._alrProject, (ActionListener) this);
ifrCur.addInternalFrameListener((InternalFrameListener) this);
}
}
@Override
public void destroy()
{
try
{
_saveViewers();
}
catch(Exception exc)
{
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.info("exc caught, don't care");
}
super.destroy();
GfrMdlSttSngSelTlo.getInstance().deleteObserver((Observer) this);
GfrMdlDspIfrRunAny.s_getInstance().deleteObserver((Observer) this);
}
@Override
public void close() throws Exception
{
try
{
_saveViewers();
}
catch(Exception exc)
{
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.info("exc caught, don't care");
}
super.close();
_setEnabledActionsOnExistingInternalViewers_(false);
//_setEnabledActionsViewersInternal(false);
}
@Override
public void open() throws Exception
{
super.open();
// ???
_setEnabledActionsOnExistingInternalViewers_(false);
//_setEnabledActionsViewersInternal(false);
}
//clean-up DB if any tbrls while saving serialized, or/and last instance exited not correctly
protected void _cleanUpViewersInDb() throws Exception
{
String[] strsIdInDb = GfrWrpBasPrsDspPrjViewersExisting.s_getInstance().getIds();
ArrayList<String> altIdsToDelete = new ArrayList<String>();
for (int i=0; i<strsIdInDb.length; i++)
{
altIdsToDelete.add(strsIdInDb[i]);
}
for (GfrIfrWinViewRunAbs frmCur: GfrHstFrmIntViewersPrsRun.s_getInstance().get())
{
if (! (frmCur instanceof GfrIfrWinViewRunIdRegSerAbs))
continue;
String strIdCur = ((GfrIfrWinViewRunIdRegSerAbs) frmCur).getUniqueId();
for (String strIdInDb: altIdsToDelete)
{
if (strIdInDb.compareTo(strIdCur) != 0)
continue;
altIdsToDelete.remove(strIdInDb);
break;
}
}
// ---
String[] strsToDeleteInDb = new String[altIdsToDelete.size()];
for (int i=0; i<strsToDeleteInDb.length; i++)
strsToDeleteInDb[i] = altIdsToDelete.get(i);
GfrWrpDspSynViewer.s_getInstance().delete(strsToDeleteInDb);
}
public void loadViewers(IHandlerLoaderSecondaryWindowsProject lst)
{
new ThreadLoadViewers(lst).start();
}
@Override
public void actionControllerToggleOnPerspectiveProjectAppli(String strNameProject) throws Exception
{
boolean blnHideAnything = GfrWrpDspLastSpaceProject.getInstance().getIsLastTabRunHideAnythingButProcessDesktop();
if (blnHideAnything)
{
if (GfrPnlStatusBarMain.s_getInstance().isVisible())
{
GfrPnlStatusBarMain.s_getInstance().setVisible(false);
super._app.getFrame().getContentPane().invalidate();
super._app.getFrame().getContentPane().repaint();
}
}
else
{
if (! GfrPnlStatusBarMain.s_getInstance().isVisible())
{
GfrPnlStatusBarMain.s_getInstance().setVisible(true);
super._app.getFrame().getContentPane().invalidate();
super._app.getFrame().getContentPane().repaint();
}
}
super.actionControllerToggleOnPerspectiveProjectAppli(strNameProject);
}
@Override
public void actionControllerToggleOffPerspective() throws Exception
{
boolean blnIsVisibleStatusBar = GfrPnlStatusBarMain.s_getInstance().isVisible();
GfrWrpDspLastSpaceProject.getInstance().setIsLastTabRunHideAnythingButProcessDesktop(! blnIsVisibleStatusBar);
if (! blnIsVisibleStatusBar)
{
GfrPnlStatusBarMain.s_getInstance().setVisible(true);
super._app.getFrame().getContentPane().invalidate();
super._app.getFrame().getContentPane().repaint();
}
super.actionControllerToggleOffPerspective();
}
public void tileWindowsInternalHandler() throws Exception
{
tileViewersInternal();
}
public void tileHorizontallyWindowsInternalHandler() throws Exception
{
tileHorizontallyViewersInternal();
}
public void tileVerticallyWindowsInternalHandler() throws Exception
{
tileVerticallyViewersInternal();
}
public void cascadeWindowsInternalHandler() throws Exception
{
cascadeViewersInternal();
}
private boolean _blnIsAnyViewerToSave_()
{
HashSet<GfrIfrWinViewRunAbs> set = GfrHstFrmIntViewersPrsRun.s_getInstance().get();
if (set==null || set.isEmpty())
return false;
Object[] objsFrame = set.toArray();
for (Object objCur: objsFrame)
{
if (objCur instanceof GfrIfrWinViewRunIdRegVolPlgAbs)
{
boolean blnCanSave = ((GfrIfrWinViewRunIdRegVolPlgAbs) objCur).canSave();
if (blnCanSave)
return true;
}
if (objCur instanceof GfrIfrWinViewRunIdSpcPlgVolTloAbs)
{
boolean blnCanSave = ((GfrIfrWinViewRunIdSpcPlgVolTloAbs) objCur).canSave();
if (blnCanSave)
return true;
}
}
return false;
}
private void _doSaveViewers_()
{
HashSet<GfrIfrWinViewRunAbs> set = GfrHstFrmIntViewersPrsRun.s_getInstance().get();
if (set==null || set.isEmpty())
return;
Object[] objsFrame = set.toArray();
for (Object objCur: objsFrame)
{
if (objCur instanceof GfrIfrWinViewRunIdRegVolPlgAbs)
{
boolean blnCanSave = ((GfrIfrWinViewRunIdRegVolPlgAbs) objCur).canSave();
if (! blnCanSave)
continue;
((GfrIfrWinViewRunIdRegVolPlgAbs) objCur).doSave();
continue;
}
if (objCur instanceof GfrIfrWinViewRunIdSpcPlgVolTloAbs)
{
boolean blnCanSave = ((GfrIfrWinViewRunIdSpcPlgVolTloAbs) objCur).canSave();
if (! blnCanSave)
continue;
((GfrIfrWinViewRunIdSpcPlgVolTloAbs) objCur).doSave();
continue;
}
}
}
// ----
// internal viewers
public void closeAllWindowsInternalHandler() throws Exception
{
boolean blnAnyViewerToSave = _blnIsAnyViewerToSave_();
if (blnAnyViewerToSave)
{
String[] options = new String[] {"Save and close all", "Close all", "Cancel"};
String strTitle = "Close all viewers";
String strMessage = "There are unsaved viewers.";
strMessage += "\n\n";
strMessage += "Please select an option below:";
int intResponse = JOptionPane.showOptionDialog(null, strMessage, strTitle,
JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
if (intResponse<0 || intResponse>1)
return; // action cancelled by user
if (intResponse == 0)
{
_doSaveViewers_();
}
}
else // nothing to save
{
String strBody = "Are you sure you want to close all viewers?";
// memo: from main frame
if (! GfrOptionPaneAbs.s_showDialogConfirm(
super._app.getFrame(), "Close all viewers", strBody))
{
return; // action cancelled by user
}
}
// tempo location
GfrMdlDspIfrRunAny.s_getInstance().removeAll();
HashSet<GfrIfrWinViewRunAbs> set = GfrHstFrmIntViewersPrsRun.s_getInstance().get();
Object[] objsFrame = set.toArray();
for (int i=0; i<objsFrame.length; i++)
{
GfrIfrWinViewRunAbs frmCur = (GfrIfrWinViewRunAbs) objsFrame[i];
_delete_(frmCur);
}
_setEnabledActionsOnExistingInternalViewers_(false);
// todo: update dlgManageViewers
}
// !!! TO REMOVE !!!
public void viewersHandler()
{
GfrOptionPaneAbs.s_showDialogInfo(super._app.getFrame(), "TODO: viewersHandler()");
}
@Override
public void internalFrameOpened(InternalFrameEvent e) {}
@Override
public void internalFrameClosed(InternalFrameEvent e) {}
@Override
public void internalFrameIconified(InternalFrameEvent e) {}
@Override
public void internalFrameDeiconified(InternalFrameEvent e) {}
@Override
public void internalFrameActivated(InternalFrameEvent e) {}
@Override
public void internalFrameDeactivated(InternalFrameEvent e) {}
@Override
public void internalFrameClosing(InternalFrameEvent evt)
{
Object objSource = evt.getSource();
if ( objSource instanceof GfrIfrWinViewRunAbs
/*objSource instanceof GfrIfrWinViewRunIdRegSerAppAbs ||
objSource instanceof GfrIfrWinViewRunIdRegVolPlgAbs ||
objSource instanceof GfrIfrWinViewRunIdSpcPlgVolTloAbs*/
)
{
GfrIfrWinViewRunAbs ifr = (GfrIfrWinViewRunAbs) objSource;
try
{
_delete_(ifr);
// tempo location
//GfrMdlDspIfrRunAny.s_getInstance().remove(ifr); // !!!!!!!!!!!!!!!!!!!!!!!
}
catch (Exception exc)
{
exc.printStackTrace();
String str = exc.getMessage();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(super._app.getFrame(), str);
return;
}
return;
}
String str = "uncaught action, evt.getSource().getClass().toString()=";
str += evt.getSource().getClass().toString();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(super._app.getFrame(), str);
}
@Override
public void actionPerformed(ActionEvent evt)
{
try
{
if (evt.getSource() instanceof GfrMimTrsAlrIdNewWinZoomTloJfcChartAll)
{
GfrMimTrsAlrIdAbs mim = (GfrMimTrsAlrIdAbs) evt.getSource();
String strIdTlo = mim.getId();
_windowViewerInternalTopsJcfChartHandler(strIdTlo);
return;
}
// beg internal frame
if (evt.getSource() instanceof GfrMimAlrCloseSecFrmInt)
{
GfrMimAlrCloseSecFrmInt mim = (GfrMimAlrCloseSecFrmInt) evt.getSource();
JInternalFrame ifrOwner = GfrIfrAbs.s_getInternalFrameOwner(mim);
// tempo location
GfrMdlDspIfrRunAny.s_getInstance().remove(ifrOwner); // !!!!!!!!!!!!!!!!!!!!!!!
if (ifrOwner != null)
{
if (ifrOwner instanceof GfrIfrWinViewRunIdRegSerAbs ||
ifrOwner instanceof GfrIfrWinViewRunIdRegVolPlgAbs)
_delete_((GfrIfrWinViewRunAbs) ifrOwner);
else
{
// !!!
}
}
else
{
// !!!
}
return;
}
if (evt.getSource() instanceof GfrMimAlrRenameSecFrmInt)
{
GfrMimAlrRenameSecFrmInt mim = (GfrMimAlrRenameSecFrmInt) evt.getSource();
JInternalFrame ifr = GfrIfrAbs.s_getInternalFrameOwner(mim);
if (ifr instanceof GfrIfrWinViewRunIdRegSerAbs)
{
_moveChild_((GfrIfrWinViewRunIdRegSerAbs) ifr);
}
else if (ifr instanceof GfrIfrWinViewRunIdRegVolPlgAbs)
{
_moveChild_((GfrIfrWinViewRunIdRegVolPlgAbs) ifr);
}
else
{
// !!!
return;
}
return;
}
// end internal frame
if (evt.getSource() instanceof BtnAbs)
{
BtnAbs btn = (BtnAbs) evt.getSource();
JFrame frmOwner = GfrFrmAbs.s_getFrameOwner(btn);
if (frmOwner == null)
{
String str = "frmOwner == null";
str += btn.getClass().toString();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(super._app.getFrame(), str);
return;
}
String str = "uncaught btn, btn.getClass().toString()=";
str += btn.getClass().toString();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(super._app.getFrame(), str);
return;
}
if (evt.getSource() instanceof GfrMimAbs)
{
GfrMimAbs mim = (GfrMimAbs) evt.getSource();
JFrame frmOwner = GfrFrmAbs.s_getFrameOwner(mim);
if (frmOwner == null)
{
String str = "frmOwner == null";
str += mim.getClass().toString();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(super._app.getFrame(), str);
return;
}
if (mim instanceof GfrMimAlrCloneViewer)
{
GfrOptionPaneAbs.s_showDialogInfo(frmOwner, "TODO: " + mim.getText());
return;
}
}
// ---
// end
}
catch(Exception exc)
{
exc.printStackTrace();
String str = exc.getMessage();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
return;
}
super.actionPerformed(evt);
}
// ----
// private
private void _moveChild_(GfrIfrWinViewRunIdRegSerAbs ifrSource) throws Exception
{
String strIdSource = ifrSource.getUniqueId();
String strNameSourceOld = ifrSource.getUniqueName();
String[] strsChildrenExisting =
GfrWrpBasPrsDspPrjViewersExisting.s_getInstance().getNames();
if (strsChildrenExisting != null && strsChildrenExisting.length > 1)
java.util.Arrays.sort(strsChildrenExisting, String.CASE_INSENSITIVE_ORDER);
JFrame frmOwner = null;
GfrDlgOkTextSaveRename dlg = new GfrDlgOkTextSaveRename(frmOwner,
strsChildrenExisting,
strNameSourceOld);
if (!dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
throw new Exception(str);
}
dlg.setVisible(true);
boolean blnCancelled = dlg.isCancelled();
String strValue = null;
if (! blnCancelled)
{
strValue = dlg.getValue();
}
dlg.destroy();
dlg = null;
if (blnCancelled) // action cancelled by user
return;
GfrWrpBasPrsDspPrjViewersExisting.s_getInstance().moveName(strIdSource, strValue);
ifrSource.moveName(strValue);
}
private void _moveChild_(GfrIfrWinViewRunIdRegVolPlgAbs ifrSource) throws Exception
{
String strIdSource = ifrSource.getUniqueId();
String strNameSourceOld = ifrSource.getUniqueName();
String[] strsChildrenExisting =
GfrWrpBasPrsDspPrjViewersExisting.s_getInstance().getNames();
if (strsChildrenExisting != null && strsChildrenExisting.length > 1)
java.util.Arrays.sort(strsChildrenExisting, String.CASE_INSENSITIVE_ORDER);
JFrame frmOwner = null;
GfrDlgOkTextSaveRename dlg = new GfrDlgOkTextSaveRename(frmOwner,
strsChildrenExisting,
strNameSourceOld);
if (!dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
throw new Exception(str);
}
dlg.setVisible(true);
boolean blnCancelled = dlg.isCancelled();
String strValue = null;
if (! blnCancelled)
{
strValue = dlg.getValue();
}
dlg.destroy();
dlg = null;
if (blnCancelled) // action cancelled by user
return;
GfrWrpBasPrsDspPrjViewersExisting.s_getInstance().moveName(strIdSource, strValue);
ifrSource.moveName(strValue);
}
private void _deleteWindowLloIfAnyInternal_(String strIdLlo) throws Exception
{
HashSet<GfrIfrWinViewRunAbs> set = GfrHstFrmIntViewersPrsRun.s_getInstance().get();
Object[] objsFrame = set.toArray();
for (int i=0; i<objsFrame.length; i++)
{
String strIdLloCur = null;
GfrIfrWinViewRunAbs ifr = (GfrIfrWinViewRunAbs) objsFrame[i];
if (ifr instanceof GfrIfrWinViewRunIdRegVolPlgLloAbs)
{
GfrIfrWinViewRunIdRegVolPlgLloAbs ifrLlo = (GfrIfrWinViewRunIdRegVolPlgLloAbs) ifr;
strIdLloCur = ifrLlo.getIdLlo();
}
// ---
else
continue;
// ---
if (strIdLloCur.compareTo(strIdLlo) != 0)
continue;
// ---
_delete_(ifr);
}
}
// TODO HERE !!!!!!!!!
private void _deleteWindowTloIfAnyInternal_(String strIdTlo) throws Exception
{
HashSet<GfrIfrWinViewRunAbs> set = GfrHstFrmIntViewersPrsRun.s_getInstance().get();
Object[] objsFrame = set.toArray();
for (int i=0; i<objsFrame.length; i++)
{
GfrIfrWinViewRunAbs ifr = (GfrIfrWinViewRunAbs) objsFrame[i];
String strIdTloCur = null;
if (ifr instanceof GfrIfrWinViewRunIdRegSerAppTloAbs)
{
GfrIfrWinViewRunIdRegSerAppTloAbs ifrTlo = (GfrIfrWinViewRunIdRegSerAppTloAbs) ifr;
strIdTloCur = ifrTlo.getIdTlo();
}
else if (ifr instanceof GfrIfrWinViewRunIdRegSerPlgTloAbs)
{
GfrIfrWinViewRunIdRegSerPlgTloAbs ifrTlo = (GfrIfrWinViewRunIdRegSerPlgTloAbs) ifr;
strIdTloCur = ifrTlo.getIdTlo();
}
else if (ifr instanceof GfrIfrWinViewRunIdRegVolPlgCtrTloAbs)
{
GfrIfrWinViewRunIdRegVolPlgCtrTloAbs ifrTlo = (GfrIfrWinViewRunIdRegVolPlgCtrTloAbs) ifr;
strIdTloCur = ifrTlo.getIdTlo();
}
else if (ifr instanceof GfrIfrWinViewRunIdRegVolPlgLloAbs)
{
GfrIfrWinViewRunIdRegVolPlgLloAbs ifrLlo = (GfrIfrWinViewRunIdRegVolPlgLloAbs) ifr;
strIdTloCur = ifrLlo.getIdTlo();
}
//
else
continue;
if (strIdTloCur.compareTo(strIdTlo) != 0)
continue;
// ---
_delete_(ifr);
// memo: no return coz allowing more than one window sharing saming TLO
}
}
public void deleteWindowLloIfAny(String strIdLlo) throws Exception
{
_deleteWindowLloIfAnyInternal_(strIdLlo);
}
public void deleteWindowTloIfAny(String strIdTlo) throws Exception
{
_deleteWindowTloIfAnyInternal_(strIdTlo);
}
private void _releaseViewersInternalPlugin_()
{
int intCount = GfrHstFrmIntViewersPrsRun.s_getInstance().size();
if (intCount < 1)
return;
// ---
boolean blnContainsUnsavedViewers = false;
for (GfrIfrWinViewRunAbs ifrCur: GfrHstFrmIntViewersPrsRun.s_getInstance().get())
{
if (ifrCur instanceof GfrIfrWinViewRunIdRegVolPlgAbs)
{
boolean blnCanSave = ((GfrIfrWinViewRunIdRegVolPlgAbs) ifrCur).canSave();
if (blnCanSave)
{
blnContainsUnsavedViewers = true;
break;
}
}
if (ifrCur instanceof GfrIfrWinViewRunIdSpcPlgVolTloAbs)
{
boolean blnCanSave = ((GfrIfrWinViewRunIdSpcPlgVolTloAbs) ifrCur).canSave();
if (blnCanSave)
{
blnContainsUnsavedViewers = true;
break;
}
}
}
boolean blnSaveUnsavedViewers = false;
if (blnContainsUnsavedViewers)
blnSaveUnsavedViewers = _confirmSaveViewersBeforeExiting_();
// ---
boolean blnOk = true;
for (GfrIfrWinViewRunAbs ifrCur: GfrHstFrmIntViewersPrsRun.s_getInstance().get())
{
// !!!!!!!!!!!!!!!!! RATHER USE INTERFACES !!!!!!!!!!!!!!!!!!!!
if (!(ifrCur instanceof GfrIfrWinViewRunIdRegSerSimplePlg) &&
!(ifrCur instanceof GfrIfrWinViewRunSimplestVolPlg) &&
!(ifrCur instanceof GfrIfrWinViewRunIdRegSerPlgAbs) &&
!(ifrCur instanceof GfrIfrWinViewRunIdRegVolPlgAbs) &&
!(ifrCur instanceof GfrIfrWinViewRunIdSpcPlgVolTloAbs)
)
continue;
if (blnSaveUnsavedViewers && ifrCur instanceof GfrIfrWinViewRunIdRegVolPlgAbs)
{
boolean blnCanSave = ((GfrIfrWinViewRunIdRegVolPlgAbs) ifrCur).canSave();
if (blnCanSave)
{
((GfrIfrWinViewRunIdRegVolPlgAbs) ifrCur).doSave();
}
}
else if (blnSaveUnsavedViewers && ifrCur instanceof GfrIfrWinViewRunIdSpcPlgVolTloAbs)
{
boolean blnCanSave = ((GfrIfrWinViewRunIdSpcPlgVolTloAbs) ifrCur).canSave();
if (blnCanSave)
{
((GfrIfrWinViewRunIdSpcPlgVolTloAbs) ifrCur).doSave();
}
}
try
{
ifrCur.removeInternalFrameListener((InternalFrameListener) AcrPlgIfrRun.getInstance());
if (ifrCur instanceof GfrIfrWinViewRunIdRegSerAbs)
{
((GfrIfrWinViewRunIdRegSerAbs) ifrCur).removeActionListenerPerspectiveRun((ActionListener) AcrPlgIfrRun.getInstance());
((GfrIfrWinViewRunIdRegSerAbs) ifrCur).releaseUnserializedObject();
}
}
catch (Exception exc)
{
blnOk = false;
exc.printStackTrace();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.warning(exc.getMessage());
}
}
if (!blnOk)
{
String str = "Failed to release plugin's viewers properly, more in log file";
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
}
}
private boolean _confirmSaveViewersBeforeExiting_()
{
GfrDlgCmdCancelOkConfirmAbs dlg = new GfrDlgCmdCancelOkConfirmSaveViewers();
dlg.init();
dlg.setVisible(true);
boolean blnCancelled = dlg.isCancelled();
dlg.destroy();
dlg = null;
if (blnCancelled)
return false;//Action cancelled by user
return true;
}
private void _releaseViewersInternalApplication_()
{
int intCount = GfrHstFrmIntViewersPrsRun.s_getInstance().size();
if (intCount < 1)
return;
boolean blnOk = true;
for (GfrIfrWinViewRunAbs ifrCur: GfrHstFrmIntViewersPrsRun.s_getInstance().get())
{
if (! (ifrCur instanceof GfrIfrWinViewRunIdRegSerAppAbs))
continue;
if (ifrCur instanceof GfrIfrWinViewRunIdRegSerAppTopsWwdEarthAbs)
{
GfrIfrWinViewRunIdRegSerAppTopsWwdEarthAbs ifrWwdEarthApp = (GfrIfrWinViewRunIdRegSerAppTopsWwdEarthAbs) ifrCur;
String strState = ifrWwdEarthApp.getRestorableStateOrbitView();
if (strState != null)
{
GfrSerializeStateWwdSec.s_write(strState, ifrWwdEarthApp.getUniqueId());
}
}
try
{
ifrCur.removeInternalFrameListener((InternalFrameListener) this);
((GfrIfrWinViewRunIdRegSerAbs) ifrCur).removeActionListenerPerspectiveRun((ActionListener) this);
((GfrIfrWinViewRunIdRegSerAbs) ifrCur).releaseUnserializedObject();
}
catch (Exception exc)
{
blnOk = false;
exc.printStackTrace();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(exc.getMessage());
}
}
if (!blnOk)
{
String str = "Failed to release application's viewers properly, more in log file";
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
}
}
// final classes should clean DpnInstance
protected void _saveViewersInternal()
{
_releaseViewersInternalApplication_();
_releaseViewersInternalPlugin_();
System.gc();
_writeViewersInternalApplication_();
_writeViewersInternalPlugin_();
GfrHstFrmIntViewersPrsRun.s_getInstance().clear();
}
// cannot invoke later coz of if exiting appli, runnable is never called !!!
private void _writeViewersInternalPlugin_()
{
boolean blnOk = true;
for (GfrIfrWinViewRunAbs ifrCur: GfrHstFrmIntViewersPrsRun.s_getInstance().get())
{
if (! (ifrCur instanceof GfrIfrWinViewRunIdRegSerSimplePlg) &&
! (ifrCur instanceof GfrIfrWinViewRunIdRegSerPlgAbs)
)
continue;
try
{
GfrSerializeFrameSecViewerIntPlg.s_getInstance().write((GfrIfrWinViewRunIdRegSerAbs) ifrCur);
if (ifrCur.isVisible())
ifrCur.setVisible(false);
ifrCur.destroy();
ifrCur.dispose(); // !!!!!!!!!!
ifrCur = null;
}
catch (Exception exc)
{
blnOk = false;
exc.printStackTrace();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(exc.getMessage());
}
}
if (! blnOk)
{
String str = "Failed to write viewers properly, more in log file";
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
}
}
// cannot invoke later coz of if exiting appli, runnable is never called !!!
protected void _writeViewersInternalApplication_()
{
/*try
{
System.err.println("beg sleeping");
Thread.sleep(10000l);
System.err.println("end sleeping");
}
catch (InterruptedException ex)
{
Logger.getLogger(GfrAcrAppPrsRunAbs.class.getName()).log(Level.SEVERE, null, ex);
}*/
boolean blnOk = true;
for (GfrIfrWinViewRunAbs ifrCur: GfrHstFrmIntViewersPrsRun.s_getInstance().get())
{
if (! (ifrCur instanceof GfrIfrWinViewRunIdRegSerAppAbs))
continue;
try
{
GfrSerializeFrameSecViewerIntApp.s_getInstance().write((GfrIfrWinViewRunIdRegSerAbs) ifrCur);
if (ifrCur.isVisible())
ifrCur.setVisible(false);
ifrCur.destroy();
ifrCur.dispose(); // !!!!!!!!!!
ifrCur = null;
}
catch (Exception exc)
{
blnOk = false;
exc.printStackTrace();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(exc.getMessage());
}
}
if (! blnOk)
{
String str = "Failed to write viewers properly, more in log file";
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
}
}
protected void _saveViewers()
{
_saveViewersInternal();
}
// ---
private void _delete_(GfrIfrWinViewRunAbs ifr) throws Exception
{
// beg app
if (ifr instanceof GfrIfrWinViewRunIdRegSerAppAbs)
{
ifr.removeInternalFrameListener(this);
ifr.removeActionListenerPerspectiveRun(this);
((GfrIfrWinViewRunIdRegSerAbs) ifr).releaseUnserializedObject();
((GfrIfrWinViewRunIdRegSerAbs) ifr).deleteSerial(); // deleting recBounds, may be in try-catch !!!!!! created in line above !!!
GfrWrpDspSynViewer.s_getInstance().delete(((GfrIfrWinViewRunIdAbs) ifr).getUniqueId());
}
// end app
// beg plg
else if (ifr instanceof GfrIfrWinViewRunIdRegSerPlgAbs)
{
ifr.removeInternalFrameListener(AcrPlgIfrRun.getInstance());
ifr.removeActionListenerPerspectiveRun(AcrPlgIfrRun.getInstance());
((GfrIfrWinViewRunIdRegSerAbs) ifr).releaseUnserializedObject();
((GfrIfrWinViewRunIdRegSerAbs) ifr).deleteSerial(); // deleting recBounds, may be in try-catch !!!!!! created in line above !!!
GfrWrpDspSynViewer.s_getInstance().delete(((GfrIfrWinViewRunIdAbs) ifr).getUniqueId());
}
else if (ifr instanceof GfrIfrWinViewRunIdRegSerSimplePlg)
{
ifr.removeInternalFrameListener(AcrPlgIfrRun.getInstance());
ifr.removeActionListenerPerspectiveRun(AcrPlgIfrRun.getInstance());
((GfrIfrWinViewRunIdRegSerAbs) ifr).releaseUnserializedObject();
((GfrIfrWinViewRunIdRegSerAbs) ifr).deleteSerial(); // deleting recBounds, may be in try-catch !!!!!! created in line above !!!
}
else if (ifr instanceof GfrIfrWinViewRunIdRegVolPlgAbs)
{
ifr.removeInternalFrameListener(AcrPlgIfrRun.getInstance());
ifr.removeActionListenerPerspectiveRun(AcrPlgIfrRun.getInstance());
GfrWrpDspSynViewer.s_getInstance().delete(((GfrIfrWinViewRunIdAbs) ifr).getUniqueId());
}
else if (ifr instanceof GfrIfrWinViewRunIdSpcPlgVolTloAbs)
{
ifr.removeInternalFrameListener(AcrPlgIfrRun.getInstance());
ifr.removeActionListenerPerspectiveRun(AcrPlgIfrRun.getInstance());
GfrWrpDspSynViewer.s_getInstance().delete(((GfrIfrWinViewRunIdAbs) ifr).getUniqueId());
}
else if (ifr instanceof GfrIfrWinViewRunIdRegVolPlgLloAbs)
{
ifr.removeInternalFrameListener(AcrPlgIfrRun.getInstance());
ifr.removeActionListenerPerspectiveRun(AcrPlgIfrRun.getInstance());
GfrWrpDspSynViewer.s_getInstance().delete(((GfrIfrWinViewRunIdAbs) ifr).getUniqueId());
}
//
else if (ifr instanceof GfrIfrWinViewRunSimplestVolPlg)
{
ifr.removeInternalFrameListener(AcrPlgIfrRun.getInstance());
}
// end plg
else
{
String strSevere = "Uncaught instanceof ifr: " + ifr.getClass().toString();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(strSevere);
throw new Exception(strSevere);
}
// already serialized in frame container
if (! GfrHstFrmIntViewersPrsRun.s_getInstance().remove(ifr))
{
String str = "! GfrHstFrmIntViewersPrsRun.s_getInstance().remove(ifr)";
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
throw new Exception(str);
}
if (ifr instanceof GfrIfrWinViewRunIdRegSerAppTopsWwdEarthAbs)
{
GfrSerializeStateWwdSec.s_deleteFile(((GfrIfrWinViewRunIdRegSerAbs) ifr).getUniqueId());
}
if (ifr.isVisible())
ifr.setVisible(false);
ifr.destroy();
ifr.dispose(); // !!!!!!!!!!
ifr = null; // !!!!
// ???? now there is a model and listeners for that !!!!!!!!!!!!!!!!!!!!!!
if (GfrHstFrmIntViewersPrsRun.s_getInstance().size() < 1)
{
_setEnabledActionsOnExistingInternalViewers_(false);
// TODO: cascade
}
}
// beg inner-classes|interfaces
class ThreadLoadViewers extends GfrThr
{
// for now, just one listener
private List<IHandlerLoaderSecondaryWindowsProject> _lstListeners_ = new ArrayList<IHandlerLoaderSecondaryWindowsProject>();
private ThreadLoadViewers(IHandlerLoaderSecondaryWindowsProject lst)
{
super(ThreadLoadViewers.class.getName());
super.setDaemon(true); // !!!!
super.setPriority(Thread.MIN_PRIORITY);
if (lst != null)
this.addListener(lst);
}
public void addListener(IHandlerLoaderSecondaryWindowsProject toAdd)
{
this._lstListeners_.add(toAdd);
}
private void _notifyListeners_()
{
for (IHandlerLoaderSecondaryWindowsProject lstCur: this._lstListeners_)
lstCur.loadedSecondaryWindowsProject();
}
@Override
public void run()
{
try
{
GfrPnlStatusBarMain.s_getInstance().setBusy("Loading viewers ...");
//_loadViewersExternal(); ANM
_loadSerializedViewersInternal();
_cleanUpViewersInDb();
//_updateContentsDialogManageChildren(); ANM
GfrPnlStatusBarMain.s_getInstance().unsetBusy();
//System.out.println("Done: ThreadLoadViewers.run(), this.getName()=" + this.getName());
}
catch (Exception exc)
{
GfrPnlStatusBarMain.s_getInstance().unsetBusy();
exc.printStackTrace();
String str = exc.getMessage();
GfrAcrSpcAppPrsPrjRunAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
}
this._notifyListeners_();
}
}
// end inner-classes|interfaces
}