Issue #851 removed obsolete GFE code.

Change-Id: I3713b0e265bec9e32cde3c20bc4dae12f6b20a02

Former-commit-id: c91b6fc2c506096f37f175e8196f9aaeb356141d
This commit is contained in:
Ron Anderson 2012-07-30 15:34:16 -05:00
parent aa5b16537f
commit d87c0b6c4b
13 changed files with 0 additions and 1786 deletions

View file

@ -62,10 +62,6 @@
<command id="com.raytheon.viz.gfe.actions.ShowEditActionsDialog"
name="Edit Action Dialog">
</command>
<command
id="com.raytheon.viz.gfe.actions.ShowDefineProceduresDialogAction"
name="ShowDefineProceduresDialogAction">
</command>
<command id="com.raytheon.viz.gfe.actions.ExpandTimeScale"
name="ExpandTimeScale">
</command>
@ -417,14 +413,6 @@
<activeWhen>
<reference definitionId="com.raytheon.viz.gfe.inGFEActionSet">
</reference>
</activeWhen>
</handler>
<handler
class="com.raytheon.viz.gfe.actions.ShowDefineProceduresDialogAction"
commandId="com.raytheon.viz.gfe.actions.ShowDefineProceduresDialogAction">
<activeWhen>
<reference definitionId="com.raytheon.viz.gfe.inGFEActionSet">
</reference>
</activeWhen>
</handler>
<handler class="com.raytheon.viz.gfe.actions.ExpandTimeScale"

View file

@ -1,64 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
/**
*
*/
package com.raytheon.viz.gfe.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.viz.gfe.dialogs.DefineProceduresDialog;
/**
* @author wldougher
*
*/
public class ShowDefineProceduresDialogAction extends AbstractHandler {
private DefineProceduresDialog dialog = null;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
* ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
// If the dialog doesn't exist, create one, otherwise call its open method
if (dialog == null) {
dialog = new DefineProceduresDialog(shell);
dialog.open();
dialog = null;
} else {
dialog.open();
}
return null;
}
}

View file

@ -1,163 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
/**
*
*/
package com.raytheon.viz.gfe.core.script.action;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.CopyInputValidator;
import com.raytheon.viz.gfe.core.script.ExistMode;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite;
import com.raytheon.viz.gfe.dialogs.ScriptNameInputDialog;
/**
* An Action the user can select to copy an existing script to a new name.
*
* @author wldougher
*
*/
public class CopyAction extends Action {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(CopyAction.class);
/**
* The name of the script, i.e., "Extrapolate"
*/
protected String script;
/**
* The decorated script name, i.e., "Extrapolate.py"
*/
protected String scriptf;
/**
* A utility class instance for this script type
*/
IScriptUtil util;
/**
* Constructor.
*/
public CopyAction(String script, IScriptUtil util) {
super("Copy");
this.script = script;
this.util = util;
scriptf = util.scripted(script);
}
/**
* Display a dialog to the user that asks for the name of the destination of
* the copy. If the user enters a valid script name and clicks OK, perform
* the copy.
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
// Set up user-input dialog
Shell shell = Display.getCurrent().getActiveShell();
ScriptNameInputDialog copyNameDialog = new ScriptNameInputDialog(shell,
"Copy " + script, "Copy Name", null, new CopyInputValidator(
script, util), util);
copyNameDialog.setMode(ExistMode.ERR_EXISTS);
String type = util.getScriptType();
// Get the new name from the user
int rtnCode = copyNameDialog.open();
if (Window.OK == rtnCode) {
String newName = copyNameDialog.getValue();
try {
// do the work
LocalizationFile newScript = util.copy(script, newName,
LocalizationLevel.USER, Overwrite.SAFE);
if (newScript != null) {
File file = newScript.getFile();
BufferedReader reader = null;
BufferedWriter writer = null;
StringBuilder fileContents = new StringBuilder();
try {
reader = new BufferedReader(new FileReader(file));
for (String line = reader.readLine(); line != null; line = reader
.readLine()) {
fileContents.append(line);
fileContents.append(System
.getProperty("line.separator"));
}
String newFileContents = fileContents.toString()
.replaceAll("# " + script, "# " + newName);
newFileContents = newFileContents.replaceAll("def "
+ script, "def " + newName);
writer = new BufferedWriter(new FileWriter(file));
writer.write(newFileContents);
} catch (IOException e) {
statusHandler.handle(Priority.PROBLEM,
"Error copying " + type + " " + script, e);
} finally {
try {
if (reader != null) {
reader.close();
}
if (writer != null) {
writer.close();
}
} catch (IOException e) {
statusHandler.handle(Priority.PROBLEM,
"Error copying " + type + " " + script, e);
}
}
newScript.save();
}
statusHandler.handle(Priority.VERBOSE, type + " " + script
+ " copied to " + newName);
} catch (LocalizationException e) {
statusHandler.handle(Priority.PROBLEM, "Error copying "
+ type + " " + script, e);
} catch (GFEException e) {
statusHandler.handle(Priority.PROBLEM, "Error copying "
+ type + " " + script, e);
}
}
}
}

View file

@ -1,93 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
/**
*
*/
package com.raytheon.viz.gfe.core.script.action;
import java.io.File;
import org.eclipse.jface.action.Action;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.ui.AccessMgr;
/**
* Action to delete a script.
*
* @author wldougher
*
*/
public class DeleteAction extends Action {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(DeleteAction.class);
protected String scriptName;
protected IScriptUtil util;
/**
* Constructor
*
* @param scriptName
* The simple name of the script to be deleted.
* @param util
* The utility object that will actually delete the script
*/
public DeleteAction(String scriptName, IScriptUtil util) {
super("Delete");
this.scriptName = scriptName;
this.util = util;
}
/**
* Delete the procedure this action is tied to.
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
String path = util.getScriptTypePathPrefix() + File.separator
+ scriptName;
path = util.scripted(path);
if (AccessMgr.verifyDelete(path, LocalizationType.CAVE_STATIC, false)) {
try {
// Delete the script
util.delete(scriptName, LocalizationLevel.USER);
statusHandler.handle(Priority.VERBOSE, "USER "
+ util.getScriptType() + " " + scriptName
+ " deleted.");
} catch (GFEException e) {
statusHandler.handle(Priority.PROBLEM,
"Error deleting USER " + util.getScriptType() + " "
+ scriptName, e);
}
}
}
}

View file

@ -1,134 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
/**
*
*/
package com.raytheon.viz.gfe.core.script.action;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.PythonUtil;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite;
/**
* @author wldougher
*
*/
public class ModifyAction extends Action {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ModifyAction.class);
String scriptName;
IScriptUtil util;
public ModifyAction(String scriptName, IScriptUtil util) {
super("Modify...", Action.AS_PUSH_BUTTON);
this.scriptName = scriptName;
this.util = util;
}
@Override
public void run() {
LocalizationFile fileToEdit = null;
// get the localization file
try {
fileToEdit = util.find(scriptName, null);
} catch (GFEException e1) {
e1.printStackTrace();
}
String scriptClass = util.getScriptType();
if ((fileToEdit == null) || !fileToEdit.exists()) {
// Script has been deleted since we listed it.?
String message = String.format(
"%s \"%s\" does not exist.\nWould you like to create it?",
scriptClass, scriptName);
boolean response = MessageDialog.openConfirm(Display.getCurrent()
.getActiveShell(), "No Such Script", message);
if (response) {
try {
fileToEdit = util.createNew(scriptName,
LocalizationLevel.USER, Overwrite.SAFE);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error creating " + scriptClass + " " + scriptName,
e);
}
} else {
return;
}
} else {
LocalizationLevel level = fileToEdit.getContext()
.getLocalizationLevel();
if (LocalizationLevel.USER != level) {
String message = String
.format(
"%s \"%s\" is at %s level and cannot be modified.\n"
+ "Would you like to create an editable copy at USER level?",
scriptClass, scriptName, level);
boolean response = MessageDialog
.openConfirm(Display.getCurrent().getActiveShell(),
"Copy to USER", message);
if (response) {
try {
fileToEdit = util.copy(scriptName, scriptName,
LocalizationLevel.USER, Overwrite.SAFE);
if (fileToEdit == null) {
boolean confirmed = false;
confirmed = MessageDialog.openConfirm(Display
.getCurrent().getActiveShell(), scriptClass
+ " Already Exists", scriptClass + " "
+ scriptName
+ " already exists at USER level!\n"
+ "Are you sure you want to overwrite it?");
if (confirmed) {
fileToEdit = util.copy(scriptName, scriptName,
LocalizationLevel.USER,
Overwrite.OVERWRITE);
} else {
return;
}
}
} catch (GFEException e) {
statusHandler.handle(Priority.PROBLEM,
"Error copying " + scriptClass + " "
+ scriptName + " to USER level", e);
}
} else {
return;
}
}
}
PythonUtil.openPythonFile(fileToEdit);
}
}

View file

@ -1,99 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
/**
*
*/
package com.raytheon.viz.gfe.core.script.action;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.CopyInputValidator;
import com.raytheon.viz.gfe.core.script.ExistMode;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite;
import com.raytheon.viz.gfe.dialogs.ScriptNameInputDialog;
/**
* An Action that, when invoked, prompts the user for a new script name and
* changes the name of &quot;script&quot; to the new name.
*
* @author wldougher
*
*/
public class RenameAction extends Action {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(RenameAction.class);
protected String script;
protected IScriptUtil util;
/**
* Constructor.
*
* @param script
* The name of the script to be renamed.
* @param util
* The utility class that does the real work.
*/
public RenameAction(String script, IScriptUtil util) {
super("Rename...");
this.script = script;
this.util = util;
}
/**
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
// Set up a dialog to get the new name
Shell parent = Display.getCurrent().getActiveShell();
String type = util.getScriptType();
String title = "Rename " + type + " " + script;
IInputValidator validator = new CopyInputValidator(script, util);
ScriptNameInputDialog renameDialog = new ScriptNameInputDialog(parent,
title, "Name", script, validator, util);
renameDialog.setMode(ExistMode.ERR_EXISTS);
// Get the new name from the user
int code = renameDialog.open();
if (Window.OK == code) {
String dest = renameDialog.getValue();
try {
// Rename the script
util.rename(script, dest, LocalizationLevel.USER,
Overwrite.SAFE);
} catch (GFEException e) {
statusHandler.handle(Priority.PROBLEM, "Error renaming "
+ type + " " + script + " to " + dest + ".", e);
}
}
}
}

View file

@ -1,174 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
/**
*
*/
package com.raytheon.viz.gfe.core.script.action;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite;
/**
* An action to upgrade a script (currently, a procedure, text product or text
* utility) and make it the SITE script.
*
* @author wldougher
*
*/
public class SiteAction extends Action {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(SiteAction.class);
private static final Pattern OVR_PATTERN = Pattern.compile(
"(.+?)_?overrides", Pattern.CASE_INSENSITIVE);
String script;
IScriptUtil util;
/**
* @param script
* The simple name of the script, i.e., "OAX_APD"
* @param util
* The script utility instance that provides low-level
* script-manipulation methods
*/
public SiteAction(String script, IScriptUtil util) {
super("Make SITE");
this.script = script;
this.util = util;
}
/**
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
String scriptType = util.getScriptType();
LocalizationFile source = null;
try {
source = util.find(script, null);
} catch (GFEException e) {
String message = String.format(
"An error occurred while finding '%s'", script);
statusHandler.handle(Priority.PROBLEM, message, e);
return;
}
// Make sure the source exists
if (source == null) {
String message = String.format("%s '%s' does not exist", util
.getScriptType(), script);
MessageDialog.openError(Display.getCurrent().getActiveShell(),
"Does Not Exist", message);
statusHandler.handle(Priority.PROBLEM, message);
return;
}
LocalizationLevel srcLevel = source.getContext().getLocalizationLevel();
String dest = script;
Matcher ovrMatch = OVR_PATTERN.matcher(script);
boolean isOverride = ovrMatch.matches();
if (isOverride) {
// strip "overrides" or "_overrides" from destination name
dest = ovrMatch.group(1);
}
if (LocalizationLevel.BASE == srcLevel) {
// source is BASE, we can't downgrade it
String message = String
.format(
"%s '%s' is at BASE level and cannot be moved to SITE level.",
scriptType, script);
MessageDialog.openInformation(
Display.getCurrent().getActiveShell(), "Cannot Move Base",
message);
return;
}
if (LocalizationLevel.SITE == srcLevel && !isOverride) {
// nothing to do
String message = String.format("%s '%s' is already at SITE level.",
scriptType, script);
MessageDialog.openInformation(
Display.getCurrent().getActiveShell(), message, message);
return;
}
LocalizationFile destlf = null;
try {
destlf = util.find(dest, LocalizationLevel.SITE);
} catch (GFEException e1) {
String message = String.format("Error during search for %s '%s'",
scriptType, dest);
statusHandler.handle(Priority.PROBLEM, message);
return;
}
if (destlf != null) {
// destination already exists. Confirm overwrite.
String message = String
.format(
"%s '%s' already exists at SITE level!\n"
+ "Confirm that you want to overwrite it from %s at %s level:",
scriptType, dest, script, srcLevel.toString());
boolean confirmed = MessageDialog.openConfirm(Display.getCurrent()
.getActiveShell(), "Confirm Overwrite", message);
if (confirmed) {
try {
destlf.delete();
} catch (Exception e) {
String errMessage = String.format("Error deleting %s '%s'",
scriptType, dest);
statusHandler.handle(Priority.PROBLEM, errMessage, e);
}
} else {
return;
}
}
try {
util.copy(script, dest, LocalizationLevel.SITE, Overwrite.SAFE);
source.delete();
String message = String.format("%s '%s' set as SITE", scriptType,
dest);
statusHandler.handle(Priority.VERBOSE, message);
} catch (Exception e) {
String message = String.format("Error moving %s to SITE", script);
statusHandler.handle(Priority.PROBLEM, message, e);
}
}
}

View file

@ -1,177 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
/**
*
*/
package com.raytheon.viz.gfe.core.script.action;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite;
/**
* An action to upgrade a script (a text product or text utility) and make it
* the SITE override script.
*
* @author wldougher
*
*/
public class SiteOverrideAction extends Action {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(SiteOverrideAction.class);
private static final Pattern OVR_PATTERN = Pattern.compile(
"(.+?)_?overrides", Pattern.CASE_INSENSITIVE);
String script;
IScriptUtil util;
public SiteOverrideAction(String script, IScriptUtil util) {
super("Make SITE Override");
this.script = script;
this.util = util;
}
/**
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
String scriptType = util.getScriptType();
LocalizationFile source = null;
try {
source = util.find(script, null);
} catch (GFEException e) {
String message = String.format(
"An error occurred while finding '%s'", script);
statusHandler.handle(Priority.PROBLEM, message, e);
return;
}
// Make sure the source exists
if (source == null) {
String message = String.format("%s '%s' does not exist", util
.getScriptType(), script);
MessageDialog.openError(Display.getCurrent().getActiveShell(),
"Does Not Exist", message);
statusHandler.handle(Priority.PROBLEM, message);
return;
}
LocalizationLevel srcLevel = source.getContext().getLocalizationLevel();
String dest = script;
Matcher ovrMatch = OVR_PATTERN.matcher(script);
boolean isOverride = ovrMatch.matches();
if (isOverride) {
// strip "override" or "_override" from destination name
dest = ovrMatch.group(1);
}
if (LocalizationLevel.BASE == srcLevel) {
// source is BASE, we can't downgrade it
String message = String
.format(
"%s '%s' is at BASE level and cannot be moved to SITE level.",
scriptType, script);
MessageDialog.openInformation(
Display.getCurrent().getActiveShell(), "Cannot Move Base",
message);
return;
}
if (LocalizationLevel.SITE == srcLevel) {
// nothing to do, in two flavors:
String message = null;
if (isOverride) {
message = String.format(
"%s '%s' is already the site override.", scriptType,
script);
} else {
message = String.format("'%s' is the SITE %s.\n"
+ "It cannot be made the SITE override.", script,
scriptType);
}
MessageDialog.openInformation(
Display.getCurrent().getActiveShell(), message, message);
return;
}
dest = dest + "_OVERRIDE";
LocalizationFile destlf = null;
try {
destlf = util.find(dest, LocalizationLevel.SITE);
} catch (GFEException e1) {
String message = String.format("Error during search for %s '%s'",
scriptType, dest);
statusHandler.handle(Priority.PROBLEM, message);
return;
}
if (destlf != null) {
// destination already exists. Confirm overwrite.
String message = String
.format(
"%s '%s' already exists at SITE level!\n"
+ "Confirm that you want to overwrite it from %s at %s level:",
scriptType, dest, script, srcLevel.toString());
boolean confirmed = MessageDialog.openConfirm(Display.getCurrent()
.getActiveShell(), "Confirm Overwrite", message);
if (confirmed) {
try {
destlf.delete();
} catch (Exception e) {
String errMessage = String.format("Error deleting %s '%s'",
scriptType, dest);
statusHandler.handle(Priority.PROBLEM, errMessage, e);
}
} else {
return;
}
}
try {
util.copy(script, dest, LocalizationLevel.SITE, Overwrite.SAFE);
source.delete();
String message = String.format("%s '%s' set as SITE", scriptType,
dest);
statusHandler.handle(Priority.VERBOSE, message);
} catch (Exception e) {
String message = String.format("Error ", script);
statusHandler.handle(Priority.PROBLEM, message, e);
}
}
}

View file

@ -1,89 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.gfe.core.script.action;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.PythonUtil;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
/**
* Action to view a file (read only)
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 5, 2010 #4956 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class ViewAction extends Action {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ViewAction.class);
String scriptName;
IScriptUtil util;
public ViewAction(String scriptName, IScriptUtil util) {
super("View...", Action.AS_PUSH_BUTTON);
this.scriptName = scriptName;
this.util = util;
}
@Override
public void run() {
LocalizationFile fileToView = null;
// get the localization file
try {
fileToView = util.find(scriptName, null);
} catch (GFEException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
String scriptClass = util.getScriptType();
if ((fileToView == null) || !fileToView.exists()) {
// Script has been deleted since we listed it.?
String message = String.format("%s \"%s\" does not exist.",
scriptClass, scriptName);
MessageDialog.openError(Display.getCurrent().getActiveShell(),
"No Such Script", message);
return;
}
PythonUtil.openPythonFile(fileToView);
}
}

View file

@ -1,319 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.gfe.dialogs;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.localization.FileUpdatedMessage;
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.core.script.action.NewAction;
import com.raytheon.viz.gfe.procedures.ProcedureCatalog;
import com.raytheon.viz.gfe.procedures.ProcedureMouseListener;
import com.raytheon.viz.gfe.procedures.util.ProcedureUtil;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
/**
* Dialog for the define procedures action. Derived from the
* DefineTextProductsDialog
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sept 18, 2008 askripsk Initial creation.
* Oct 15, 2009 wldougher Derived from DefineTextProductsDialog
* </pre>
*
* @author askripsk
* @version 1.0
*/
public class DefineProceduresDialog extends CaveJFACEDialog {
public static final int CLOSE_ID = 2;
private static final int HEIGHT = 330;
private String title;
private Shell shell;
private List proceduresList;
private Label proceduresLabel;
private Composite comp;
private MenuItem newItem;
private MenuItem newProcedureItem;
// private ITextProductListChangedListener listListener;
@SuppressWarnings("unused")
private Button closeButton;
private ProcedureCatalog catalog;
private ILocalizationFileObserver observer;
/**
* Constructor
*
* @param parentShell
* the shell in which the dialog should appear.
* @param dialogTitle
* The text to display in the dialog titlebar.
*/
public DefineProceduresDialog(Shell parentShell) {
super(parentShell);
this.title = "Define Procedures";
this.setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE);
catalog = new ProcedureCatalog();
observer = new ILocalizationFileObserver() {
/**
* Update proceduresList when scripts are added or deleted.
*
* @see com.raytheon.uf.common.localization.ILocalizationFileObserver#fileUpdated(com.raytheon.uf.common.localization.FileUpdatedMessage)
*/
@Override
public void fileUpdated(FileUpdatedMessage message) {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
loadProcedures();
}
});
}
};
catalog.addObserver(observer);
}
@Override
public boolean close() {
catalog.removeObserver(observer);
observer = null;
catalog = null;
return super.close();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
*/
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == CLOSE_ID) {
close();
}
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets
* .Shell)
*/
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
if (title != null) {
shell.setText(title);
}
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse
* .swt.widgets.Composite)
*/
@Override
protected void createButtonsForButtonBar(Composite parent) {
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER
| GridData.VERTICAL_ALIGN_CENTER);
parent.setLayoutData(data);
this.closeButton = createButton(parent, CLOSE_ID, "Close", true);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveJFACEDialog#createContents(org.eclipse
* .swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Control contents = super.createContents(parent);
getShell().setLocation(getInitialLocation(getShell().getSize()));
return contents;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
* .Composite)
*/
@Override
protected Control createDialogArea(final Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
createMenuBar(parent);
comp = new Composite(composite, SWT.NONE);
comp.setLayout(new GridLayout(1, false));
comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// Setup list labels
initProceduresLabel();
// Create Lists
initProceduresList();
applyDialogFont(composite);
return composite;
}
/**
* Create the menu bar. The menubar has one option ("File"), and allows the
* user to create a new procedure or close this dialog.
*
* @param parent
*/
protected void createMenuBar(Composite parent) {
shell = parent.getShell();
Menu menuBar = new Menu(shell, SWT.BAR);
shell.setMenuBar(menuBar);
shell.setSize(250, HEIGHT);
// file menu item
MenuItem file = new MenuItem(menuBar, SWT.CASCADE);
file.setText("File");
Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
file.setMenu(fileMenu);
newItem = new MenuItem(fileMenu, SWT.CASCADE);
newItem.setText("New Item In Window...");
// TODO: add selection listener
new MenuItem(fileMenu, SWT.SEPARATOR);
MenuItem closeItem = new MenuItem(fileMenu, SWT.PUSH);
closeItem.setText("Close");
closeItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
close();
}
});
Menu newMenu = new Menu(newItem);
newProcedureItem = new MenuItem(newMenu, SWT.PUSH);
newProcedureItem.setText("Procedures");
newProcedureItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IScriptUtil util = new ProcedureUtil();
Action anAction = new NewAction(util);
anAction.run();
}
});
newItem.setMenu(newMenu);
}
/**
* Initialize the proceduresLabel variable.
*/
private void initProceduresLabel() {
proceduresLabel = new Label(comp, SWT.NONE);
proceduresLabel.setText("Procedures");
proceduresLabel.setLayoutData(new GridData(SWT.CENTER, SWT.NONE, false,
false));
}
/**
* Create proceduresList, fill it with the procedure names, and connect it
* to the mouse listener for performing actions (modify, delete, etc.).
*/
private void initProceduresList() {
proceduresList = new List(comp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
layoutData.heightHint = proceduresList.getItemHeight() * 10;
layoutData.widthHint = 150;
proceduresList.setLayoutData(layoutData);
loadProcedures();
proceduresList.addMouseListener(new ProcedureMouseListener());
}
/**
* Set the contents of proceduresList to all the Python scripts in the GFE
* procedures directory.
*/
private void loadProcedures() {
proceduresList.removeAll();
Set<String> procs = new HashSet<String>();
procs.addAll(catalog.getNames());
String[] procedures = procs.toArray(new String[0]);
Arrays.sort(procedures, String.CASE_INSENSITIVE_ORDER);
for (String procedure : procedures) {
proceduresList.add(procedure);
}
}
}

View file

@ -1,133 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
/**
*
*/
package com.raytheon.viz.gfe.procedures;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Menu;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.AbstractScriptCatalog;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.core.script.action.CopyAction;
import com.raytheon.viz.gfe.core.script.action.DeleteAction;
import com.raytheon.viz.gfe.core.script.action.ModifyAction;
import com.raytheon.viz.gfe.core.script.action.NewAction;
import com.raytheon.viz.gfe.core.script.action.RenameAction;
import com.raytheon.viz.gfe.core.script.action.SiteAction;
import com.raytheon.viz.gfe.core.script.action.ViewAction;
import com.raytheon.viz.gfe.procedures.util.ProcedureUtil;
/**
* A mouse listener for the procedure list in DefineProceduresDialog.
*
* @author wldougher
*
*/
public class ProcedureMouseListener extends MouseAdapter {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ProcedureMouseListener.class);
private MenuManager menuMgr;
/**
* Constructor.
*/
public ProcedureMouseListener() {
super();
}
/**
* Handle mouse button 3 presses by displaying a small menu for the
* Procedure whose name is under the cursor. Actions which are always
* available on the menu are Copy, Modify, and New (which doesn't care which
* procedure the mouse is over). When the Procedure is at USER level, Delete
* and Rename actions are also offered.
*
* @see org.eclipse.swt.events.MouseAdapter#mouseDown(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseDown(MouseEvent e) {
List list = (List) e.getSource();
String selected = list.getItem(list.getSelectionIndex());
if (e.button == 3) {
if (menuMgr == null) {
menuMgr = new MenuManager("#PopupMenu");
} else {
menuMgr.removeAll();
}
IScriptUtil util = new ProcedureUtil();
AbstractScriptCatalog catalog = new ProcedureCatalog();
menuMgr.add(new CopyAction(selected, util));
menuMgr.add(new Separator());
menuMgr.add(new ViewAction(selected, util));
menuMgr.add(new ModifyAction(selected, util));
menuMgr.add(new NewAction(util));
LocalizationFile selectedFile = null;
try {
selectedFile = util.find(selected, LocalizationLevel.USER);
} catch (GFEException e1) {
statusHandler.handle(Priority.VERBOSE,
"Error finding procedure " + selected, e1);
}
LocalizationLevel level = LocalizationLevel.BASE;
if (selectedFile != null) {
level = selectedFile.getContext().getLocalizationLevel();
}
// The Rename and Delete options should only be available on
// utilities that the user has created or copied, or to admins
// TODO: add these if user has admin role
if (LocalizationLevel.USER == level || false) {
menuMgr.add(new Separator());
menuMgr.add(new DeleteAction(selected, util));
menuMgr.add(new RenameAction(selected, util));
}
if (true) { // TODO: only if user is a site admin
if (LocalizationLevel.USER == level) {
menuMgr.add(new Separator());
menuMgr.add(new SiteAction(selected, util));
}
}
Menu menu = menuMgr.createContextMenu(list);
menu.setVisible(true);
list.setMenu(menu);
}
}
}

View file

@ -1,178 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.gfe.textproduct;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Menu;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.core.script.action.CopyAction;
import com.raytheon.viz.gfe.core.script.action.ModifyAction;
import com.raytheon.viz.gfe.core.script.action.RenameAction;
import com.raytheon.viz.gfe.core.script.action.ViewAction;
import com.raytheon.viz.gfe.textproduct.action.NewAction;
import com.raytheon.viz.gfe.textproduct.action.TextProductDeleteAction;
import com.raytheon.viz.gfe.textproduct.action.TextProductSiteAction;
import com.raytheon.viz.gfe.textproduct.action.TextProductSiteOverrideAction;
/**
* Listens to mouse events on the text products list in the
* DefineTextProductsDialog
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sept 19, 2008 askripsk Initial creation
*
* </pre>
*
* @author askripsk
* @version 1.0
*/
public class ProductMouseListener implements MouseListener {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ProductMouseListener.class);
private MenuManager menuMgr;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt
* .events.MouseEvent)
*/
@Override
public void mouseDoubleClick(MouseEvent e) {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events
* .MouseEvent)
*/
@Override
public void mouseDown(MouseEvent e) {
List list = (List) e.getSource();
String selected = list.getItem(list.getSelectionIndex());
if (e.button == 3) {
if (menuMgr == null) {
menuMgr = new MenuManager("#PopupMenu");
} else {
menuMgr.removeAll();
}
IScriptUtil util = new TextProductUtil();
menuMgr.add(new CopyAction(selected, util));
menuMgr.add(new Separator());
menuMgr.add(new ViewAction(selected, util));
menuMgr.add(new ModifyAction(selected, util));
menuMgr.add(new NewAction());
// Get the localization level of the selection
LocalizationFile script = null;
try {
script = util.find(selected, null);
} catch (GFEException e1) {
statusHandler.handle(Priority.PROBLEM,
"Unable to find script " + selected, e1);
}
LocalizationLevel level = LocalizationLevel.BASE;
if (script != null) {
level = script.getContext().getLocalizationLevel();
}
// Some text product specific Action classes were created for use
// here specifically for ticket #5074 that are largely copies of the
// Action classes in the com.raytheon.viz.gfe.core.script.action
// package with some specific changes for its unique storage
// hierarchy. They are not well-designed but I was assured that the
// design of the dialog this listener supports will be changing
// soon.
// TODO: REMOVE these classes and modify the ones within
// com.raytheon.viz.gfe.core.script.action to support both text
// products and the other python-based items that are currently
// supported.
// The Rename and Delete options should only be available on
// utilities that the user has created or copied, or to admins
// TODO: add these if user has admin role
if (LocalizationLevel.USER == level || false) {
menuMgr.add(new Separator());
menuMgr.add(new TextProductDeleteAction(selected, util));
menuMgr.add(new RenameAction(selected, util));
}
// TODO: skip if user is not site-admin
if (true) { // TODO: check user site-admin rights
if (LocalizationLevel.USER == level
|| LocalizationLevel.SITE == level) {
menuMgr.add(new Separator());
}
boolean isOverride = selected.matches("(?i).+override");
if (LocalizationLevel.USER == level) {
menuMgr.add(new TextProductSiteAction(selected, util));
if (!isOverride) {
menuMgr.add(new TextProductSiteOverrideAction(selected,
util));
}
} else if (LocalizationLevel.SITE == level) {
if (isOverride) {
menuMgr.add(new TextProductSiteAction(selected, util));
}
}
}
Menu menu = menuMgr.createContextMenu(list);
menu.setVisible(true);
list.setMenu(menu);
}
}
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.
* MouseEvent)
*/
@Override
public void mouseUp(MouseEvent arg0) {
}
}

View file

@ -1,151 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.gfe.textproduct;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Menu;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.script.IScriptUtil;
import com.raytheon.viz.gfe.core.script.action.CopyAction;
import com.raytheon.viz.gfe.core.script.action.DeleteAction;
import com.raytheon.viz.gfe.core.script.action.ModifyAction;
import com.raytheon.viz.gfe.core.script.action.NewAction;
import com.raytheon.viz.gfe.core.script.action.RenameAction;
import com.raytheon.viz.gfe.core.script.action.SiteAction;
import com.raytheon.viz.gfe.core.script.action.ViewAction;
/**
* Listens to mouse events on the text products list in the
* DefineTextProductsDialog
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sept 19, 2008 askripsk Initial creation
*
* </pre>
*
* @author askripsk
* @version 1.0
*/
public class UtilitiesMouseListener implements MouseListener {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(UtilitiesMouseListener.class);
private MenuManager menuMgr;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt
* .events.MouseEvent)
*/
@Override
public void mouseDoubleClick(MouseEvent e) {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events
* .MouseEvent)
*/
@Override
public void mouseDown(MouseEvent e) {
List list = (List) e.getSource();
String selected = list.getItem(list.getSelectionIndex());
if (e.button == 3) {
if (menuMgr == null) {
menuMgr = new MenuManager("#PopupMenu");
} else {
menuMgr.removeAll();
}
IScriptUtil util = new TextUtilityUtil();
menuMgr.add(new CopyAction(selected, util));
menuMgr.add(new Separator());
menuMgr.add(new ViewAction(selected, util));
menuMgr.add(new ModifyAction(selected, util));
menuMgr.add(new NewAction(util));
LocalizationFile script = null;
try {
script = util.find(selected, null);
} catch (GFEException e1) {
statusHandler.handle(Priority.PROBLEM,
"Error finding script " + selected, e1);
}
LocalizationLevel level = null;
if (script != null) {
level = script.getContext().getLocalizationLevel();
}
// The Rename and Delete options should only be available on
// utilities that the user has created or copied, or to admins
// TODO: add these if user has admin role
if (LocalizationLevel.USER == level || false) {
menuMgr.add(new Separator());
menuMgr.add(new DeleteAction(selected, util));
menuMgr.add(new RenameAction(selected, util));
}
if (true) { // TODO: skip if user is not site-admin
if (LocalizationLevel.USER == level) {
menuMgr.add(new Separator());
menuMgr.add(new SiteAction(selected, util));
}
}
Menu menu = menuMgr.createContextMenu(list);
menu.setVisible(true);
list.setMenu(menu);
}
}
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.
* MouseEvent)
*/
@Override
public void mouseUp(MouseEvent arg0) {
}
}