📄 applicationshortcutsform.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.forms;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.extensions.ApplicationShortcut;
import com.sslexplorer.extensions.ApplicationShortcutItem;
import com.sslexplorer.extensions.ExtensionDescriptor;
import com.sslexplorer.extensions.store.ExtensionStore;
import com.sslexplorer.policyframework.ResourceItemModel;
import com.sslexplorer.policyframework.forms.AbstractResourcesForm;
import com.sslexplorer.security.SessionInfo;
import com.sslexplorer.security.VPNSession;
/**
* Extension of
* {@link com.sslexplorer.policyframework.forms.AbstractResourcesForm} that
* provides the model for lists of <i>Application Shortcuts</i>.
*
* @author Brett Smith <a href="mailto: brett@3sp.com"><brett@3sp.com></a>
* @version $Revision: 1.7 $
*/
public class ApplicationShortcutsForm extends AbstractResourcesForm {
static Log log = LogFactory.getLog(ApplicationShortcutsForm.class);
/**
* Constant used for the <i>Icons</i> view of application shortcuts
*/
public final static String ICONS_VIEW = "icons";
/**
* Constant used for the <i>List</i> view of application shortcuts
*/
public final static String LIST_VIEW = "view";
// Private instance variables
private String selectedView;
/**
* Constructor
*/
public ApplicationShortcutsForm() {
super(new ApplicationShortcutModel());
}
/**
* Initialise the pager and the items and the ability to sort.
*
* @param applicationShortcuts List of Samples to be added.
* @param session The session information.
* @param defaultSortColumnId default sort column
* @param request request from action that initialises this form
*/
public void initialise(List applicationShortcuts, SessionInfo session, String defaultSortColumnId, HttpServletRequest request) {
super.initialize(session.getHttpSession(), defaultSortColumnId);
if (selectedView == null) {
selectedView = session.getNavigationContext() == SessionInfo.USER_CONSOLE_CONTEXT ? ICONS_VIEW : LIST_VIEW;
} else if (session.getNavigationContext() == SessionInfo.MANAGEMENT_CONSOLE_CONTEXT) {
selectedView = LIST_VIEW;
}
try {
for (Iterator i = applicationShortcuts.iterator(); i.hasNext();) {
ApplicationShortcut applicationShortcut = (ApplicationShortcut) i.next();
List policies = CoreServlet.getServlet().getPolicyDatabase().getPoliciesAttachedToResource(applicationShortcut);
ExtensionDescriptor ed = ExtensionStore.getInstance().getExtensionDescriptor(applicationShortcut.getApplication());
if (ed == null) {
log.warn("Found shortcut with an application ID (" + applicationShortcut.getApplication()
+ " that does not exist. An extension may have been removed.");
} else {
ApplicationShortcutItem item = new ApplicationShortcutItem(ed, -1, applicationShortcut, policies, session
.getNavigationContext(), applicationShortcut.sessionPasswordRequired(session));
item.setFavoriteType(getFavoriteType(applicationShortcut.getResourceId()));
VPNSession vpnSession = CoreServlet.getServlet().getLogonController().getPrimaryVPNSession(
CoreServlet.getServlet().getLogonController().getVPNSessionsByLogon(request));
item.setClientPort(vpnSession == null ? -1 : vpnSession.getClientPort());
getModel().addItem(item);
}
}
checkSort();
getPager().rebuild(getFilterText());
} catch (Throwable t) {
log.error("Failed to initialise resources form.", t);
}
}
/**
* Get the selected view. This will be one of {@link #ICONS_VIEW} or
* {@link #LIST_VIEW}.
*
* @return selected view
*/
public String getSelectedView() {
return selectedView;
}
/**
* Set the selected view. This will be one of {@link #ICONS_VIEW} or
* {@link #LIST_VIEW}.
*
* @param selectedView selected view
*/
public void setSelectedView(String selectedView) {
this.selectedView = selectedView;
}
// Supporting classes
static class ApplicationShortcutModel extends ResourceItemModel {
/**
* Constructor
*/
public ApplicationShortcutModel() {
super("applicationShortcuts");
}
public Class getColumnClass(int col) {
switch (col) {
case 2:
return String.class;
default:
return super.getColumnClass(col);
}
}
public int getColumnCount() {
return 3;
}
public String getColumnName(int col) {
switch (col) {
case 2:
return "application";
default:
return super.getColumnName(col);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -