/*
* 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 java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.io.File;
import java.util.jar.Manifest;
import java.util.logging.Logger;
import org.geoforge.appogcecl.actionmanager.GfrAmrAppSpcPrtRoot;
import org.geoforge.basprjdat.io.GfrIoBasNameDatPrjAbs;
import org.geoforge.basprjdatecl.io.GfrIoBasNameDatPrjEcl;
import org.geoforge.basprjdatogc.io.GfrIoBasNameDatPrjOgc;
import org.geoforge.basprjdspecl.io.GfrIoBasNameDspDftObjsCatPrjEcl;
import org.geoforge.basprjdspogc.io.GfrIoBasNameDspDftObjsCatPrjOgc;
import org.geoforge.basusrspcdat.io.GfrPrpNamingBasGrpChl;
import org.geoforge.basusrspcdsp.io.GfrPrpNamingBasDspUsr;
import org.geoforge.basusrspcdsp.table.GfrBasTblUsrSpcPrtHistoryAbs;
import org.geoforge.guillc.GfrAppSpcAbs;
import org.geoforge.guillc.action.*;
import org.geoforge.guillc.actioncontroller.GfrAcrSpcAppAbs;
import org.geoforge.guillc.frame.GfrFrmAbs;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.GfrPnlStatusBarMain;
import org.geoforge.guillc.actionmanager.GfrAmrAppFrmSecManageChildrenSpaceRoot;
import org.geoforge.guillc.dialog.*;
import org.geoforge.guillc.frame.GfrFrmMainAppAbs;
import org.geoforge.guillc.filechooser.GfrUtilFileChooserVol;
import org.geoforge.guillc.handler.IGfrHandlerActionControllerCanCloseSpace;
import org.geoforge.java.io.file.GfrUtilFile;
import org.geoforge.java.io.file.GfrJavIoFileExtension;
import org.geoforge.io.serial.GfrSerializeAbs;
import org.geoforge.io.serial.GfrSerializeStateWwdMan;
import org.geoforge.io.serial.GfrSerializeStateWwdSel;
import org.geoforge.io.util.jar.GfrManJarSpcWrk;
import org.geoforge.io.util.jar.JarHelper;
import org.geoforge.lang.text.GfrSimpleDateFormatAll;
import org.geoforge.lang.util.GfrResBundleLang;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldat.GfrMdlDatSpcPrtRoot;
import org.geoforge.wrpbasprsdsp.viewer.GfrWrpDspSynViewer;
import org.geoforge.wrpbasspcdatogcecl.root.GfrWrpBasDatSpcRoot;
import org.geoforge.wrpbasusr.GfrValueDateHistory;
import org.geoforge.wrpbasusr.GfrWrpUsrSpcDspPrtAppRoot;
/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
abstract public class GfrAcrSpcAppPrtRootOgcEclAbs extends GfrAcrSpcAppPrtAbs
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(GfrAcrSpcAppPrtRootOgcEclAbs.class.getName());
static
{
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
//--
private String _strKindActivity_ = null;
// 3 methods below: used to export workspace
abstract protected String _getNameDbDataWorkspaceAppli();
abstract protected String _getNameDbDataProjectAppli();
abstract protected String _getNameDbDisplayDefaultProjectAppli();
abstract protected void _newChild(String strValue) throws Exception;
protected GfrAcrSpcAppPrtRootOgcEclAbs(GfrAppSpcAbs app, String strKindActivity) throws Exception
{
super(app,
new GfrAmrAppSpcPrtRoot(),
new GfrAmrAppFrmSecManageChildrenSpaceRoot());
this._strKindActivity_ = strKindActivity;
}
@Override
public String actionControllerContainerSpaceNewChild() throws Exception
{
String[] strsChildrenExisting = GfrWrpBasDatSpcRoot.getInstance().getSortedPathsAbsolute();
GfrDlgAddFolderSpcWrkNew dlg = new GfrDlgAddFolderSpcWrkNew(
super._app.getFrame(),
strsChildrenExisting);
if (!dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(str);
throw new Exception(str);
}
dlg.setVisible(true);
boolean blnCancelled = dlg.isCancelled();
String strValue = null;
if (!blnCancelled)
{
strValue = dlg.getValuePath();
}
dlg.destroy();
if (blnCancelled) // action cancelled by user
return null;
// -- create spacework on disk
_newChild(strValue);
// ---
// update actions
updateStateActions();
// return
return strValue;
}
@Override
public void actionControllerContainerSpaceCloneChild() throws Exception
{
String strPathSource = ActionChildCloneWorkspace.s_getInstance().getChild();
if (strPathSource == null)
{
String str = "strPathSource == null";
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(str);
throw new Exception(str);
}
String[] strsChildrenExisting = GfrWrpBasDatSpcRoot.getInstance().getSortedPathsAbsolute();
GfrDlgAddFolderSpcWrkCopy dlg = new GfrDlgAddFolderSpcWrkCopy(
super._app.getFrame(),
strsChildrenExisting,
strPathSource);
if (!dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(str);
throw new Exception(str);
}
dlg.setVisible(true);
boolean blnCancelled = dlg.isCancelled();
String strValue = null;
if (!blnCancelled)
strValue = dlg.getValuePath();
dlg.destroy();
dlg = null;
if (blnCancelled) // action cancelled by user
return;
// -----
// beg doJob
GfrMdlDatSpcPrtRoot.getInstance().cloneChild(strPathSource, strValue);
}
@Override
public void updateStateActions() throws Exception
{
String[] strsChildrenExisting = GfrWrpBasDatSpcRoot.getInstance().getSortedPathsAbsolute();
boolean blnHasWorkspace = false;
if (strsChildrenExisting != null && strsChildrenExisting.length > 0)
blnHasWorkspace = true;
// ----
// main frame
ActionOpenChildFromListSpaceWork.s_getInstance().setEnabled(blnHasWorkspace);
// ---
boolean blnIsHistory = false;
String strLastChild = GfrWrpUsrSpcDspPrtAppRoot.getInstance().getValueLastChildFromHistory();
if (strLastChild!=null && strLastChild.length()>0)
blnIsHistory = true;
ActionOpenChildFromHistSpaceWork.s_getInstance().setEnabled(blnIsHistory);
ActionOpenChildLastSpaceWork.s_getInstance().setEnabled(blnIsHistory);
// ---
// ----
// dialogManagerChildren
ActionDeleteWorkspaces.s_getInstance().setEnabled(blnHasWorkspace);
}
@Override
public void actionControllerContainerSpaceDeleteChildren() throws Exception
{
if (!GfrOptionPaneAbs.s_showDialogConfirm(GfrFrmAbs.s_getFrameOwner(GfrPnlStatusBarMain.s_getInstance()),
GfrResBundleLang.s_getInstance().getValue("verb.confirm"),
GfrResBundleLang.s_getInstance().getValue("sentence.confirmDeleteWorkspaces")))
return;
GfrMdlDatSpcPrtRoot.getInstance().deleteAllChildren();
updateStateActions();
}
@Override
public void actionControllerContainerSpaceDeleteChild() throws Exception
{
if (!GfrOptionPaneAbs.s_showDialogConfirm(GfrFrmAbs.s_getFrameOwner(GfrPnlStatusBarMain.s_getInstance()),
GfrResBundleLang.s_getInstance().getValue("verb.confirm"),
GfrResBundleLang.s_getInstance().getValue("sentence.confirmDeleteWorkspace")))
return; // action cancellled by user
// job on-disk
String strPathSource = ActionChildDeleteWorkspace.s_getInstance().getChild();
GfrMdlDatSpcPrtRoot.getInstance().deleteChild(strPathSource);
// update
updateStateActions();
}
@Override
public void preferencesAppliHandler()
{
try
{
DlgAbs dlg = new GfrDlgTabsPrefsSpcRoot();
if (!dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(str);
throw new Exception(str);
}
dlg.setVisible(true);
}
catch (Exception exc)
{
exc.printStackTrace();
String str = exc.getMessage();
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
}
}
@Override
public void destroy()
{
if (this._kedCleanUpWorkspaces != null)
{
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this._kedCleanUpWorkspaces);
this._kedCleanUpWorkspaces = null;
}
String strTypeDisplay = GfrPnlStatusBarMain.s_getInstance().getTypeDisplay();
// ??? rather hard-coded ??? than internationalized !!!!!!!!!!!!!!!!
if (strTypeDisplay.compareTo(GfrResBundleLang.s_getInstance().getValue("word.desktop")) == 0)
{
try
{
super.actionControllerClose();
}
catch (Exception exc)
{
exc.printStackTrace();
String str = exc.getMessage();
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
//return;
}
}
super.destroy();
}
public void manageChildrenWorkspacesHandler() throws Exception
{
actionControllerContainerManageChildren();
}
public void newAndOpenChildWorkspaceHandler() throws Exception
{
newAndOpenChild();
}
public String newChildWorkspaceHandler() throws Exception
{
return actionControllerContainerSpaceNewChild();
}
// at launching time
public void displayGrandChild(String strName) throws Exception
{
((GfrAcrSpcAppPrtAbs) super._acrChild).displayChild(strName);
}
// at launching time
@Override
public void displayChild(String strPath) throws Exception
{
GfrWrpUsrSpcDspPrtAppRoot.getInstance().setLast(GfrBasTblUsrSpcPrtHistoryAbs.STR_WHO_LAST_ONE_OF_MY_CHILDREN,
strPath);
((IGfrHandlerActionControllerCanCloseSpace) super._acrChild).actionControllerOpenSpace(strPath);
if (!super._app.getFrame().isVisible()) // always false!
{
super._app.getFrame().toFront();
super._app.getFrame().setVisible(true);
}
}
@Override
public void openChild(String strPathAbsolute) throws Exception
{
super.actionControllerClose(); // unload spaceroot's actions
((GfrFrmMainAppAbs) super._app.getFrame()).closeSpaceRoot();
try
{
displayChild(strPathAbsolute);
GfrMdlDatSpcPrtRoot.getInstance().openChild(strPathAbsolute);
}
catch (Exception exc)
{
exc.printStackTrace();
System.out.println("AcrSpcPrtRootOgcAbs : exc caught, don't care");
open();
}
}
public void openChildLastWorkspaceHandler() throws Exception
{
openChildLast();
}
public void openChildFromHistWorkspaceHandler() throws Exception
{
openChildFromHistory();
}
public void openChildFromListWorkspaceHandler() throws Exception
{
openChildFromList();
}
public void deleteWorkspacesHandler() throws Exception
{
actionControllerContainerSpaceDeleteChildren();
}
public void deleteChildWorkspaceHandler() throws Exception
{
actionControllerContainerSpaceDeleteChild();
}
@Override
public void actionControllerContainerManageChildren() throws Exception
{
String[] strsChildrenExisting = GfrWrpBasDatSpcRoot.getInstance().getSortedPathsAbsolute();
Object[][] objssData;
if (strsChildrenExisting == null)
objssData = new Object[0][0];
else
{
int intNbCols = 2;
objssData = new Object[strsChildrenExisting.length][intNbCols];
for (int i = 0; i < strsChildrenExisting.length; i++)
{
objssData[i][0] = strsChildrenExisting[i];
// tempo code below
objssData[i][1] = this._strKindActivity_;
}
}
if (super._dlgManageChildren == null)
{
super._dlgManageChildren = new GfrDlgManageChildrenSpcWrk(
super._app.getFrame(),
objssData,
_strKindActivity_);
if (!super._dlgManageChildren.init())
throw new Exception("! super._dlgManageChildren_.init()");
}
super._dlgManageChildren.setVisible(true);
}
@Override
public void newAndOpenChild() throws Exception
{
String strValue = newChildWorkspaceHandler();
if (strValue != null)
openChild(strValue);
}
protected KeyEventDispatcher _kedCleanUpWorkspaces = null;
// used here at first run, or if user has previously exited from root
@Override
public void open() throws Exception
{
GfrWrpUsrSpcDspPrtAppRoot.getInstance().setLast(GfrBasTblUsrSpcPrtHistoryAbs.STR_WHO_LAST_ME);
super.open();
this.updateStateActions();
this.actionControllerContainerUpdateContentsDialogManageChildren();
((GfrFrmMainAppAbs) super._app.getFrame()).openSpaceRoot(); // root
if (!super._app.getFrame().isVisible())
super._app.getFrame().setVisible(true);
}
@Override
public void close() throws Exception
{
if (this._kedCleanUpWorkspaces != null)
{
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this._kedCleanUpWorkspaces);
this._kedCleanUpWorkspaces = null;
}
super.close();
}
@Override
public void closeChild() throws Exception
{
this.open();
}
@Override
public void openChildLast() throws Exception
{
String strValue = GfrWrpUsrSpcDspPrtAppRoot.getInstance().getValueLastChildFromHistory();
openChild(strValue);
}
@Override
public void openChildFromHistory() throws Exception
{
Object[] objsChildren = GfrWrpUsrSpcDspPrtAppRoot.getInstance().getArrayValueDateChildrenFromHistory();
Object[][] objss = new Object[objsChildren.length][];
for (int i=objsChildren.length; i>0; i--)
{
objss[objsChildren.length - i] = new Object[2];
GfrValueDateHistory vdhCur = (GfrValueDateHistory) objsChildren[i-1];
String strDate = GfrSimpleDateFormatAll.s_format(vdhCur.getGregCal().getTime());
//System.out.println("i=" + i + ", value=" + vdhCur.getValue() + ", lastAccessed=" + strDate);
objss[objsChildren.length - i][0] = vdhCur.getValue();
objss[objsChildren.length - i][1] = strDate;
}
GfrDlgOpenSpaceFromHistoryWork dlg = new GfrDlgOpenSpaceFromHistoryWork(
super._app.getFrame(),
objss);
if (! dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrtRootOgcEclAbs._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)
return; // action cancelled by user
// ------
// do job
openChild(strValue);
}
@Override
public void openChildFromList() throws Exception
{
String[] strsChildrenExisting = GfrWrpBasDatSpcRoot.getInstance().getSortedPathsAbsolute();
GfrDlgOpenSpaceFromListWork dlg = new GfrDlgOpenSpaceFromListWork(
super._app.getFrame(),
strsChildrenExisting);
if (!dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrtRootOgcEclAbs._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)
return; // action cancelled by user
// ------
// do job
openChild(strValue);
}
public void importWorkspaceHandler() throws Exception
{
File fleJarFileSource = GfrUtilFileChooserVol.s_getOpenFile(
super._app.getFrame(),
GfrJavIoFileExtension.STRS_EXTENSION_WORKSPACE,
GfrJavIoFileExtension.STR_DESCRIPTION_WORKSPACE);
if (fleJarFileSource == null)
return; // cancelled by user
String[] strsChildrenExisting = GfrWrpBasDatSpcRoot.getInstance().getSortedPathsAbsolute();
GfrDlgAddFolderSpcWrkNew dlg = new GfrDlgAddFolderSpcWrkNew(
super._app.getFrame(),
strsChildrenExisting);
if (!dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(str);
throw new Exception(str);
}
dlg.setVisible(true);
boolean blnCancelled = dlg.isCancelled();
String strValue = null;
if (!blnCancelled)
{
strValue = dlg.getValuePath();
}
dlg.destroy();
dlg = null;
if (blnCancelled) // action cancelled by user
return;
File fleDirTarget = new File(strValue);
// ---
String strError = GfrManJarSpcWrk.s_check(fleJarFileSource);
if (strError != null)
{
String strMessage = "Failed to import workspace:";
strMessage += "\n " + fleJarFileSource.getAbsolutePath();
strMessage += "\n\nto file:";
strMessage += "\n " + fleDirTarget.getAbsolutePath();
strMessage += "\n\n\nDetails:";
strMessage += "\n " + strError;
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.warning(strMessage);
GfrOptionPaneAbs.s_showDialogWarning(super._app.getFrame(), strMessage);
return;
}
fleDirTarget.mkdir();
JarHelper jarUtil = new JarHelper();
jarUtil.unjarDir(fleJarFileSource, fleDirTarget);
// ---
GfrWrpBasDatSpcRoot.getInstance().save(fleDirTarget.getAbsolutePath());
// update actions
updateStateActions();
// ---
GfrMdlDatSpcPrtRoot.getInstance().importChild(fleDirTarget.getAbsolutePath());
// ---
String strMessage = "Sucessfully imported workspace:";
strMessage += "\n " + fleJarFileSource.getAbsolutePath();
strMessage += "\n\nto file:";
strMessage += "\n " + fleDirTarget.getAbsolutePath();
GfrOptionPaneAbs.s_showDialogInfo(super._app.getFrame(), strMessage);
}
public void exportChildWorkspaceHandler() throws Exception
{
String strPathAbsFolderSource = ActionChildExportWorkspace.s_getInstance().getChild();
File fleJarFileTarget = GfrUtilFileChooserVol.s_chooseFileSave(
super._app.getFrame(),
"Export workspace",
"workspace",
"." + GfrJavIoFileExtension.STRS_EXTENSION_WORKSPACE[0]
);
if (fleJarFileTarget == null)
return;
File fleFolderTemp = GfrUtilFile.s_createTempFile(
"_export_space_", // strPrefix
"_works_" // strSuffix"
);
fleFolderTemp.delete();
fleFolderTemp.mkdir();
File fleFolderWorkspaceSource = new File(strPathAbsFolderSource);
File fleDataSqliteIn = null;
File fleDataSqliteOut = null;
// dataSqlite for this workspace
fleDataSqliteIn = new File(fleFolderWorkspaceSource, _getNameDbDataWorkspaceAppli());
fleDataSqliteOut = new File(fleFolderTemp, _getNameDbDataWorkspaceAppli());
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// displaySqlite
fleDataSqliteIn = new File(fleFolderWorkspaceSource, GfrPrpNamingBasDspUsr.STR_NAME_FILE_DB_SPACEWORK);
fleDataSqliteOut = new File(fleFolderTemp, GfrPrpNamingBasDspUsr.STR_NAME_FILE_DB_SPACEWORK);
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// about projects
fleDataSqliteIn = new File(fleFolderWorkspaceSource, GfrPrpNamingBasGrpChl.STR_NAME_FILE_DB_SPACEWORK);
fleDataSqliteOut = new File(fleFolderTemp, GfrPrpNamingBasGrpChl.STR_NAME_FILE_DB_SPACEWORK);
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// for each projects
// should rather read above sqlite file, done quickly!!!!!!
File[] listOfFiles = fleFolderWorkspaceSource.listFiles();
for (File fleProjectSourceCur: listOfFiles)
{
if (! fleProjectSourceCur.isDirectory())
continue;
// ---
String strNameFolderProjectCur = fleProjectSourceCur.getName();
File fleProjectTargetCur = new File(fleFolderTemp, strNameFolderProjectCur);
fleProjectTargetCur.mkdir();
// ---
// ogcDbSqlite
fleDataSqliteIn = new File(fleProjectSourceCur, GfrIoBasNameDatPrjOgc.STR_FILE);
fleDataSqliteOut = new File(fleProjectTargetCur, GfrIoBasNameDatPrjOgc.STR_FILE);
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// ---
// eclDbSqlite
fleDataSqliteIn = new File(fleProjectSourceCur, GfrIoBasNameDatPrjEcl.STR_FILE);
fleDataSqliteOut = new File(fleProjectTargetCur, GfrIoBasNameDatPrjEcl.STR_FILE);
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// ---
// [xxx]DbSqlite
fleDataSqliteIn = new File(fleProjectSourceCur, _getNameDbDataProjectAppli());
fleDataSqliteOut = new File(fleProjectTargetCur, _getNameDbDataProjectAppli());
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// ---
// ---
// displaySqlite
// ATTN: clean-up all related to serialized viewers
fleDataSqliteIn = new File(fleProjectSourceCur, GfrPrpNamingBasDspUsr.STR_NAME_FILE_DB_SPACEPROJECT);
fleDataSqliteOut = new File(fleProjectTargetCur, GfrPrpNamingBasDspUsr.STR_NAME_FILE_DB_SPACEPROJECT);
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// beg clean-up system-dependent
GfrWrpDspSynViewer.s_getInstance().deleteAll(fleDataSqliteOut);
// end clean-up system-dependent
// ---
// displaySqliteOgc
fleDataSqliteIn = new File(fleProjectSourceCur, GfrIoBasNameDspDftObjsCatPrjOgc.STR_FILE);
fleDataSqliteOut = new File(fleProjectTargetCur, GfrIoBasNameDspDftObjsCatPrjOgc.STR_FILE);
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// ---
// displaySqliteEcl
fleDataSqliteIn = new File(fleProjectSourceCur, GfrIoBasNameDspDftObjsCatPrjEcl.STR_FILE);
fleDataSqliteOut = new File(fleProjectTargetCur, GfrIoBasNameDspDftObjsCatPrjEcl.STR_FILE);
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// ---
// displaySqliteGtc
fleDataSqliteIn = new File(fleProjectSourceCur, _getNameDbDisplayDefaultProjectAppli());
fleDataSqliteOut = new File(fleProjectTargetCur, _getNameDbDisplayDefaultProjectAppli());
GfrUtilFile.s_copy(fleDataSqliteIn, fleDataSqliteOut);
// ---
// recursively store contents of folder named data
File fleDataFolderSourceCur = new File(fleProjectSourceCur, GfrIoBasNameDatPrjAbs.STR_NAME_FOLDER_DATA);
if (! fleDataFolderSourceCur.exists())
{
String strError = "! fleDataFolderSourceCur.exists(), fleDataFolderSourceCur.getAbsolutePath()=" + fleDataFolderSourceCur.getAbsolutePath();
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(strError);
throw new Exception(strError);
}
if (! fleDataFolderSourceCur.isDirectory())
{
String strError = "! fleDataFolderSourceCur.isDirectory(), fleDataFolderSourceCur.getAbsolutePath()=" + fleDataFolderSourceCur.getAbsolutePath();
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(strError);
throw new Exception(strError);
}
File fleDataFolderTargetCur = new File(fleProjectTargetCur, GfrIoBasNameDatPrjAbs.STR_NAME_FOLDER_DATA);
GfrUtilFile.s_copyDirectory(fleDataFolderSourceCur, fleDataFolderTargetCur);
// ---
// serial: only stateWwd[Manage|Select].xml
File fleSerialFolderSourceCur = new File(fleProjectSourceCur, GfrSerializeAbs.NAME_FOLDER);
if (fleSerialFolderSourceCur.exists())
{
// ---
if (! fleSerialFolderSourceCur.isDirectory())
{
String strError = "! fleSerialFolderSourceCur.isDirectory(), fleSerialFolderSourceCur.getAbsolutePath()=" + fleSerialFolderSourceCur.getAbsolutePath();
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(strError);
throw new Exception(strError);
}
File fleSerialFolderTargetCur = new File(fleProjectTargetCur, GfrSerializeAbs.NAME_FOLDER);
fleSerialFolderTargetCur.mkdir();
File fleXmlSourceCur = null;
File fleXmlTargetCur = null;
// --- manage
fleXmlSourceCur = new File(fleSerialFolderSourceCur, GfrSerializeStateWwdMan.s_getNameFile());
fleXmlTargetCur = new File(fleSerialFolderTargetCur, GfrSerializeStateWwdMan.s_getNameFile());
if (fleXmlSourceCur.exists())
GfrUtilFile.s_copy(fleXmlSourceCur, fleXmlTargetCur);
// --- select
fleXmlSourceCur = new File(fleSerialFolderSourceCur, GfrSerializeStateWwdSel.s_getNameFile());
fleXmlTargetCur = new File(fleSerialFolderTargetCur, GfrSerializeStateWwdSel.s_getNameFile());
if (fleXmlSourceCur.exists())
GfrUtilFile.s_copy(fleXmlSourceCur, fleXmlTargetCur);
}
// end serial
}
// jarring
/*
* ATTN: tempo directory not deleted !!!!!!!!
*/
Manifest man = GfrManJarSpcWrk.s_create();
JarHelper jarUtil = new JarHelper(man);
jarUtil.jarDir(fleFolderTemp, fleJarFileTarget);
String strMessage = "Sucessfully exported workspace:";
strMessage += "\n " + strPathAbsFolderSource;
strMessage += "\n\nto file:";
strMessage += "\n " + fleJarFileTarget.getAbsolutePath();
GfrOptionPaneAbs.s_showDialogInfo(super._app.getFrame(), strMessage);
}
public void cloneChildWorkspaceHandler() throws Exception
{
actionControllerContainerSpaceCloneChild();
}
public void moveChildWorkspaceHandler() throws Exception
{
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.info("moveChildWorkspaceHandler()");
actionControllerContainerSpaceMoveChild();
}
@Override
public void actionControllerOpenSpace(String str) throws Exception
{
throw new UnsupportedOperationException("DEV CODING ERROR: spaceroot has no string as argument");
}
@Override
public GfrAcrSpcAppAbs getChild()
{
return super._acrChild;
}
@Override
public void actionControllerContainerSpaceMoveChild() throws Exception
{
String strPathSource = ActionChildMoveWorkspace.s_getInstance().getChild();
if (strPathSource == null)
{
String str = "strPathSource == null";
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(str);
throw new Exception(str);
}
String[] strsChildrenExisting = GfrWrpBasDatSpcRoot.getInstance().getSortedPathsAbsolute();
GfrDlgAddFolderSpcWrkMove dlg = new GfrDlgAddFolderSpcWrkMove(super._app.getFrame(), strsChildrenExisting,
strPathSource);
if (!dlg.init())
{
String str = "! dlg.init()";
GfrAcrSpcAppPrtRootOgcEclAbs._LOGGER_.severe(str);
throw new Exception(str);
}
dlg.setVisible(true);
boolean blnCancelled = dlg.isCancelled();
String strValue = null;
if (!blnCancelled)
strValue = dlg.getValuePath();
dlg.destroy();
dlg = null;
if (blnCancelled) // action cancelled by user
return;
GfrMdlDatSpcPrtRoot.getInstance().moveChild(strPathSource, strValue);
}
// !!! now just called once while opening root
// else dialog takes care of himself
@Override
public void actionControllerContainerUpdateContentsDialogManageChildren() throws Exception
{
if (super._dlgManageChildren == null)
return;
if (!super._dlgManageChildren.isVisible())
return;
String[] strsChildrenExisting = GfrWrpBasDatSpcRoot.getInstance().getSortedPathsAbsolute();
Object[][] objssData = null;
if (strsChildrenExisting == null)
objssData = new Object[0][0];
else
{
int intNbCols = 2;
objssData = new Object[strsChildrenExisting.length][intNbCols];
for (int i = 0; i < strsChildrenExisting.length; i++)
{
objssData[i][0] = strsChildrenExisting[i];
// tempo code below
objssData[i][1] = this._strKindActivity_;
}
}
((GfrDlgManageChildrenSpcAbs) super._dlgManageChildren).fill(objssData);
}
}