📄 applicationshortcutitem.java
字号:
/*
* SSL-Explorer
*
* Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package com.sslexplorer.extensions;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.sslexplorer.boot.Util;
import com.sslexplorer.core.CoreUtil;
import com.sslexplorer.core.DocumentOpenJavascriptLink;
import com.sslexplorer.navigation.RequiresSessionPasswordAbstractFavoriteItem;
import com.sslexplorer.security.SessionInfo;
/**
* Wrapper for {@link com.sslexplorer.extensions.ApplicationShortcut} instances.
*
* @author Brett Smith <a href="mailto: brett@3sp.com"><brett@3sp.com></a>
* @version $Revision: 1.9 $
*/
public class ApplicationShortcutItem extends RequiresSessionPasswordAbstractFavoriteItem {
// Private instance variables
private ExtensionDescriptor application;
private int clientPort;
private int navigationContext;
/**
* Constructor
*
* @param application application extension descriptor
* @param clientPort port on which VPN client is running
* @param resource application shortcut resource
* @param policies policies attached to resource
*/
public ApplicationShortcutItem(ExtensionDescriptor application, int clientPort, ApplicationShortcut resource, List policies, int navigationContext, boolean requiresSessionPassword) {
super(resource, policies, requiresSessionPassword);
this.application = application;
this.clientPort = clientPort;
this.navigationContext = navigationContext;
}
/**
* Set the port on which the VPN client is running or -1 if it is not
* currently running.
*
* @param clientPort VPN client port
*/
public void setClientPort(int clientPort) {
this.clientPort = clientPort;
}
/**
* Get the port on which the VPN client is running or -1 if it is not
* currently running.
*
* @return VPN client port
*/
public int getClientPort() {
return clientPort;
}
/**
* Get the extension descriptor of the application this shortcut requires
*
* @return extension description
*/
public ExtensionDescriptor getExtensionDescriptor() {
return application;
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.FavoriteItem#getOnClick()
*/
public String getOnClick() {
if (this.getRequiresSessionPassword()){
return new DocumentOpenJavascriptLink("/promptForSessionPassword.do?forwardTo=" + Util.urlEncode(prepareOnClick())).toJavascript();
}
else{
return prepareOnClick();
}
}
String prepareOnClick() {
String onClick = ((ApplicationLauncherType) application.getExtensionType()).getOnClick(this);
return onClick == null ? "return true" : onClick;
}
/**
* Get the link used to start this application shortcut using the
* user application shortcuts page as the referer.
*
* @return link
*/
public String getLink() {
return getLink(navigationContext == SessionInfo.MANAGEMENT_CONSOLE_CONTEXT ? "/showApplicationShortcuts.do?action=list" : "/showUserApplicationShortcuts.do?action=list");
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.FavoriteItem#getLink(java.lang.String)
*/
public String getLink(String referer) {
String link = ((ApplicationLauncherType) application.getExtensionType()).getLink(this, referer);
if(link == null) {
return "";
}
if (this.getRequiresSessionPassword()){
return "/promptForSessionPassword.do?forwardTo=" + Util.urlEncode(link);
}
return link;
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.AbstractFavoriteItem#getSmallIconPath(javax.servlet.http.HttpServletRequest)
*/
public String getSmallIconPath(HttpServletRequest request) {
if (application.getSmallIcon() == null) {
return CoreUtil.getThemePath(request.getSession()) + "/images/actions/runApplication.gif";
} else {
return "/fs/apps/" + application.getApplicationBundle().getId() + "/" + application.getSmallIcon();
}
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.AbstractFavoriteItem#getLargeIconPath(javax.servlet.http.HttpServletRequest)
*/
public String getLargeIconPath(HttpServletRequest request) {
if (application.getSmallIcon() == null) {
return CoreUtil.getThemePath(request.getSession()) + "/images/actions/runApplicationLarge.gif";
} else {
return "/fs/apps/" + application.getApplicationBundle().getId() + "/" + application.getLargeIcon();
}
}
/**
* Get all of the parameters as encoded URL parameter string
*
* @return parameters as encoded URL parameter string
*/
public String getParameterString() {
StringBuffer buf = new StringBuffer();
for (Iterator i = ((ApplicationShortcut) getResource()).getParameters().entrySet().iterator(); i.hasNext();) {
if (buf.length() > 0) {
buf.append("&");
}
Map.Entry entry = (Map.Entry) i.next();
buf.append(entry.getKey());
buf.append("=");
buf.append(Util.urlEncode(String.valueOf(entry.getValue())));
}
return buf.toString();
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.FavoriteItem#getName()
*/
public String getFavoriteName() {
return getResource().getResourceName();
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.AbstractFavoriteItem#getFavoriteSubType()
*/
public String getFavoriteSubType() {
return getExtensionDescriptor().getName();
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.FavoriteItem#getTarget()
*/
public String getTarget() {
return "_self";
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.table.TableItem#getColumnValue(int)
*/
public Object getColumnValue(int col) {
switch (col) {
case 2:
return application.getName();
default:
return super.getColumnValue(col);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -