listener.loadMessages();
listener.loadJobTitels();
listener.loadHolidaysTitel();
Options.loadWindow(sShell, "editor");
menuBar = new Menu(sShell, SWT.BAR);
MenuItem submenuItem2 = new MenuItem(menuBar, SWT.CASCADE);
submenuItem2.setText("&File");
mFile = new Menu(submenuItem2);
MenuItem open = new MenuItem(mFile, SWT.PUSH);
open.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if (container.openQuick() != null)
setSaveStatus();
}
});
open.setText("Open \tCtrl+O");
open.setAccelerator(SWT.CTRL | 'O');
MenuItem mNew = new MenuItem(mFile, SWT.CASCADE);
mNew.setText("New ");
Menu pmNew = new Menu(mNew);
MenuItem pNew = new MenuItem(pmNew, SWT.PUSH);
pNew.setText("Configuration \tCtrl+I");
pNew.setAccelerator(SWT.CTRL | 'I');
pNew.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (container.newScheduler() != null)
setSaveStatus();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
mNew.setMenu(pmNew);
MenuItem push1 = new MenuItem(pmNew, SWT.PUSH);
push1.setText("Documentation \tCtrl+P"); // Generated
push1.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (container.newDocumentation() != null)
setSaveStatus();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
//new event handler
MenuItem pNewActions = new MenuItem(pmNew, SWT.PUSH);
pNewActions.setText("Event Handler \tCTRL+X");
pNewActions.setAccelerator(SWT.CTRL | 'X');
pNewActions.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (container.newActions() != null)
setSaveStatus();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
MenuItem mpLife = new MenuItem(pmNew, SWT.CASCADE);
mpLife.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
}
});
mpLife.setText("Hot Folder Element \tCtrl+L");
mpLife.setAccelerator(SWT.CTRL | 'L');
Menu mLife = new Menu(mpLife);
MenuItem mLifeJob = new MenuItem(mLife, SWT.PUSH);
mLifeJob.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if (container.newScheduler(SchedulerDom.LIFE_JOB) != null)
setSaveStatus();
}
});
mLifeJob.setText("Job \tCtrl+J");
mLifeJob.setAccelerator(SWT.CTRL | 'J');
mpLife.setMenu(mLife);
MenuItem mLifeJobChain = new MenuItem(mLife, SWT.PUSH);
mLifeJobChain.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if (container.newScheduler(SchedulerDom.LIFE_JOB_CHAIN) != null)
setSaveStatus();
}
});
mLifeJobChain.setText("Job Chain \tCtrl+K");
mLifeJobChain.setAccelerator(SWT.CTRL | 'K');
MenuItem mLifeProcessClass = new MenuItem(mLife, SWT.PUSH);
mLifeProcessClass.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if (container.newScheduler(SchedulerDom.LIFE_PROCESS_CLASS) != null)
setSaveStatus();
}
});
mLifeProcessClass.setText("Process Class \tCtrl+R");
mLifeProcessClass.setAccelerator(SWT.CTRL | 'R');
MenuItem mLifeLock = new MenuItem(mLife, SWT.PUSH);
mLifeLock.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if (container.newScheduler(SchedulerDom.LIFE_LOCK) != null)
setSaveStatus();
}
});
mLifeLock.setText("Lock \tCtrl+M");
mLifeLock.setAccelerator(SWT.CTRL | 'M');
MenuItem mLifeOrder= new MenuItem(mLife, SWT.PUSH);
mLifeOrder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if (container.newScheduler(SchedulerDom.LIFE_ORDER) != null)
setSaveStatus();
}
});
mLifeOrder.setText("Order \tCtrl+W");
mLifeOrder.setAccelerator(SWT.CTRL | 'W');
MenuItem mLifeSchedule= new MenuItem(mLife, SWT.PUSH);
mLifeSchedule.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if (container.newScheduler(SchedulerDom.LIFE_SCHEDULE) != null)
setSaveStatus();
}
});
mLifeSchedule.setText("Schedule \tCtrl+K");
mLifeSchedule.setAccelerator(SWT.CTRL | 'K');
new MenuItem(mFile, SWT.SEPARATOR);
MenuItem openDir = new MenuItem(mFile, SWT.PUSH);
openDir.setText("Open Hot Folder \tCtrl+D");
openDir.setAccelerator(SWT.CTRL | 'D');
openDir.setEnabled(true);
openDir.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (container.openDirectory(null) != null)
setSaveStatus();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
//open remote configuration
MenuItem mORC = new MenuItem(mFile, SWT.CASCADE);
mORC.setText("Open Remote Configuration");
Menu pMOpenGlobalScheduler = new Menu(mORC);
MenuItem pOpenGlobalScheduler = new MenuItem(pMOpenGlobalScheduler, SWT.PUSH);
pOpenGlobalScheduler.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
Utils.startCursor(getSShell());
String globalSchedulerPath = Options.getSchedulerData().endsWith("/") || Options.getSchedulerData().endsWith("\\") ? Options.getSchedulerData() : Options.getSchedulerData() + "/";
globalSchedulerPath = globalSchedulerPath + "config/remote/_all";
File f = new java.io.File(globalSchedulerPath);
if(!f.exists()) {
if(!f.mkdirs()) {
MainWindow.message("could not create Global Scheduler Configurations: " + globalSchedulerPath, SWT.ICON_WARNING);
Utils.stopCursor(getSShell());
return;
}
}
if (container.openDirectory(globalSchedulerPath) != null)
setSaveStatus();
Utils.stopCursor(getSShell());
}
});
pOpenGlobalScheduler.setText("Open Global Scheduler");
MenuItem pOpenSchedulerCluster = new MenuItem(pMOpenGlobalScheduler, SWT.PUSH);
pOpenSchedulerCluster.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
HotFolderDialog dialog = new HotFolderDialog();
dialog.showForm(HotFolderDialog.SCHEDULER_CLUSTER);
}
});
pOpenSchedulerCluster.setText("Open Cluster Configuration");
MenuItem pOpenSchedulerHost = new MenuItem(pMOpenGlobalScheduler, SWT.PUSH);
pOpenSchedulerHost.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
HotFolderDialog dialog = new HotFolderDialog();
dialog.showForm(HotFolderDialog.SCHEDULER_HOST);
}
});
pOpenSchedulerHost.setText("Open Remote Scheduler Configuration");
mORC.setMenu(pMOpenGlobalScheduler);
new MenuItem(mFile, SWT.SEPARATOR);
MenuItem pSaveFile = new MenuItem(mFile, SWT.PUSH);
pSaveFile.setText("Save \tCtrl+S");
pSaveFile.setAccelerator(SWT.CTRL | 'S');
pSaveFile.setEnabled(false);
pSaveFile.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
save();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
MenuItem pSaveAs = new MenuItem(mFile, SWT.PUSH);
pSaveAs.setText("Save As ");
pSaveAs.setEnabled(false);
pSaveAs.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (container.getCurrentEditor() != null && container.getCurrentEditor().applyChanges()) {
if(container.getCurrentTab().getData("ftp_title") != null) {
container.getCurrentTab().setData("ftp_title", null);
container.getCurrentTab().setData("ftp_profile_name", null);
container.getCurrentTab().setData("ftp_remote_directory", null);
container.getCurrentTab().setData("ftp_hot_folder_elements", null);
container.getCurrentTab().setData("ftp_profile", null);
}
container.getCurrentEditor().saveAs();
setSaveStatus();
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
MenuItem pSaveAsHotFolderElement = new MenuItem(mFile, SWT.PUSH);
pSaveAsHotFolderElement.setText("Save As Hot Folder Elements \tCtrl+B");
pSaveAsHotFolderElement.setAccelerator(SWT.CTRL | 'B');
pSaveAsHotFolderElement.setEnabled(false);
pSaveAsHotFolderElement.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (container.getCurrentEditor() != null && container.getCurrentEditor().applyChanges()) {
SchedulerForm form =(SchedulerForm)container.getCurrentEditor();
SchedulerDom currdom = (SchedulerDom)form.getDom();
if(IOUtils.saveDirectory(currdom, true, SchedulerDom.DIRECTORY, null, container)) {
Element root = currdom.getRoot();
if(root != null) {
Element config = root.getChild("config");
if(config != null) {
config.removeChildren("jobs");
config.removeChildren("job_chains");
config.removeChildren("locks");
Utils.removeChildrensWithName(config, "process_classes");
config.removeChildren("schedules");
config.removeChildren("commands");
form.updateTree("main");
form.update();
}
}
}
container.getCurrentEditor().save();
setSaveStatus();
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
new MenuItem(mFile, SWT.SEPARATOR);
// FTP
MenuItem mFTP = new MenuItem(mFile, SWT.CASCADE);
mFTP.setText("FTP");
Menu pmFTP = new Menu(mNew);
MenuItem pOpenFTP = new MenuItem(pmFTP, SWT.PUSH);
pOpenFTP.setText("Open By FTP");
pOpenFTP.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
FTPDialog ftp = new FTPDialog(main);
ftp.showForm(FTPDialog.OPEN);
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
MenuItem pOpenHotFolderFTP = new MenuItem(pmFTP, SWT.PUSH);
pOpenHotFolderFTP.setText("Open Hot Folder By FTP");
pOpenHotFolderFTP.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
FTPDialog ftp = new FTPDialog(main);
ftp.showForm(FTPDialog.OPEN_HOT_FOLDER);
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
new MenuItem(pmFTP, SWT.SEPARATOR);
MenuItem pSaveFTP = new MenuItem(pmFTP, SWT.PUSH);
pSaveFTP.setText("Save By FTP");
pSaveFTP.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
saveByFTP();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
mFTP.setMenu(pmFTP);
new MenuItem(mFile, SWT.SEPARATOR);
// WebDav
boolean existwebDavLib = existLibraries();
MenuItem mWebDav = new MenuItem(mFile, SWT.CASCADE);
mWebDav.setText("WebDav");
mWebDav.setAccelerator(SWT.CTRL | 'N');
mWebDav.setEnabled(existwebDavLib);
Menu pmWebDav = new Menu(mNew);
MenuItem pOpenWebDav = new MenuItem(pmWebDav, SWT.PUSH);
pOpenWebDav.setText("Open By WebDav");
pOpenWebDav.setEnabled(existwebDavLib);
pOpenWebDav.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
try {
if(existLibraries()) {
WebDavDialog webdav = new WebDavDialog();
webdav.showForm(WebDavDialog.OPEN);
}
} catch(Exception ex) {
try {
new sos.scheduler.editor.app.ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName() + " ; could not open file on Webdav Server", ex);
} catch(Exception ee) {
//tu nichts
}
MainWindow.message("could not open file on Webdav Server, cause: " + ex.getMessage(), SWT.ICON_WARNING);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
MenuItem pOpenHotFolderWebDav = new MenuItem(pmWebDav, SWT.PUSH);
pOpenHotFolderWebDav.setText("Open Hot Folder By WebDav");
pOpenHotFolderWebDav.setEnabled(existwebDavLib);
pOpenHotFolderWebDav.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if(existLibraries()) {
WebDavDialog webdav = new WebDavDialog();
webdav.showForm(WebDavDialog.OPEN_HOT_FOLDER);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
new MenuItem(pmWebDav, SWT.SEPARATOR);
MenuItem pSaveWebDav = new MenuItem(pmWebDav, SWT.PUSH);
pSaveWebDav.setText("Save By WebDav");
pSaveWebDav.setEnabled(existwebDavLib);
pSaveWebDav.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if(existLibraries()) {
WebDavDialog webdav = new WebDavDialog();
DomParser currdom = getSpecifiedDom();
if(currdom == null)
return;
if( currdom instanceof SchedulerDom && ((SchedulerDom)currdom).isDirectory()) {
webdav.showForm(WebDavDialog.SAVE_AS_HOT_FOLDER);
} else
webdav.showForm(WebDavDialog.SAVE_AS);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
mWebDav.setMenu(pmWebDav);
new MenuItem(mFile, SWT.SEPARATOR);
submenuItem2.setMenu(mFile);
MenuItem pExit = new MenuItem(mFile, SWT.PUSH);
pExit.setText("Exit\tCtrl+E");
pExit.setAccelerator(SWT.CTRL | 'E');
pExit.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
try {
sShell.close();
} catch(Exception es) {
try {
new ErrorLog("error: " + sos.util.SOSClassUtil.getMethodName(), es);
} catch (Exception ee){
//tu nichts
}
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
MenuItem submenuItem = new MenuItem(menuBar, SWT.CASCADE);
submenuItem.setText("Options");
MenuItem submenuItem3 = new MenuItem(menuBar, SWT.CASCADE);
submenuItem3.setText("&Help");
submenu1 = new Menu(submenuItem3);
MenuItem pHelS = new MenuItem(submenu1, SWT.PUSH);
pHelS.setText("Scheduler Editor Help");
pHelS.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
listener.openHelp(Options.getHelpURL("index"));
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
MenuItem pHelp = new MenuItem(submenu1, SWT.PUSH);
pHelp.setText("Help\tF1");
pHelp.setAccelerator(SWT.F1);
pHelp.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (container.getCurrentEditor() != null) {
listener.openHelp(container.getCurrentEditor().getHelpKey());
}else {
String msg = "Help is available after documentation or configuration is opened";
MainWindow.message(msg, SWT.ICON_INFORMATION);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
MenuItem pAbout = new MenuItem(submenu1, SWT.PUSH);
pAbout.setText("About");
pAbout.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
listener.showAbout();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
submenuItem3.setMenu(submenu1);
submenu = new Menu(submenuItem);
MenuItem submenuItem1 = new MenuItem(submenu, SWT.CASCADE);
submenuItem1.setText("Help Language");
menuLanguages = new Menu(submenuItem1);
// create languages menu
listener.setLanguages(menuLanguages);
submenuItem1.setMenu(menuLanguages);