0001: /*
0002: * Gruntspud
0003: *
0004: * Copyright (C) 2002 Brett Smith.
0005: *
0006: * Written by: Brett Smith <t_magicthize@users.sourceforge.net>
0007: *
0008: * This program is free software; you can redistribute it and/or modify it under
0009: * the terms of the GNU Library General Public License as published by the Free
0010: * Software Foundation; either version 2 of the License, or (at your option) any
0011: * later version. This program is distributed in the hope that it will be
0012: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
0014: * General Public License for more details.
0015: *
0016: * You should have received a copy of the GNU Library General Public License
0017: * along with this program; if not, write to the Free Software Foundation, Inc.,
0018: * 675 Mass Ave, Cambridge, MA 02139, USA.
0019: */
0020: package gruntspud;
0021:
0022: import gruntspud.authentication.GruntspudAuthenticator;
0023: import gruntspud.file.ChmodFileReadOnlyHandler;
0024: import gruntspud.file.FileModeHandler;
0025: import gruntspud.file.FileTypeMapping;
0026: import gruntspud.file.GruntspudFileUtils;
0027: import gruntspud.file.UnixFileModeHandler;
0028: import gruntspud.ui.LicensePanel;
0029: import gruntspud.ui.TellMeAgainPane;
0030: import gruntspud.ui.ToolBarSeparator;
0031: import gruntspud.ui.UIUtil;
0032: import gruntspud.ui.icons.OverlayIcon;
0033: import gruntspud.ui.preferences.CVSFileFilterPane;
0034: import gruntspud.ui.view.CVSFileNodeTable;
0035: import gruntspud.ui.view.CVSFileNodeTree;
0036: import java.awt.BorderLayout;
0037: import java.awt.Component;
0038: import java.awt.Dialog;
0039: import java.awt.Dimension;
0040: import java.awt.FontMetrics;
0041: import java.awt.Frame;
0042: import java.awt.GridBagConstraints;
0043: import java.awt.GridBagLayout;
0044: import java.awt.Insets;
0045: import java.awt.Window;
0046: import java.awt.event.ContainerAdapter;
0047: import java.awt.event.ContainerEvent;
0048: import java.io.File;
0049: import java.io.IOException;
0050: import java.net.Authenticator;
0051: import java.net.MalformedURLException;
0052: import java.net.URL;
0053: import java.util.StringTokenizer;
0054: import java.util.Vector;
0055: import javax.swing.Action;
0056: import javax.swing.BorderFactory;
0057: import javax.swing.JComponent;
0058: import javax.swing.JDialog;
0059: import javax.swing.JLabel;
0060: import javax.swing.JMenu;
0061: import javax.swing.JOptionPane;
0062: import javax.swing.JPanel;
0063: import javax.swing.JPopupMenu;
0064: import javax.swing.JSeparator;
0065: import javax.swing.JSplitPane;
0066: import javax.swing.JToolBar;
0067: import javax.swing.SwingConstants;
0068: import javax.swing.SwingUtilities;
0069: import javax.swing.UIManager;
0070: import org.netbeans.lib.cvsclient.command.GlobalOptions;
0071: import org.netbeans.lib.cvsclient.file.FileReadOnlyHandler;
0072: import org.netbeans.lib.cvsclient.file.FileUtils;
0073: import org.netbeans.lib.cvsclient.file.WindowsFileReadOnlyHandler;
0074: import org.netbeans.lib.cvsclient.util.Logger;
0075:
0076: /**
0077: * Description of the Class
0078: *
0079: *@author magicthize
0080: *@created 26 May 2002
0081: *
0082: * @todo
0083: */
0084: public class Gruntspud extends JPanel implements Constants {
0085: public final static String APPLICATION_NAME = "Gruntspud";
0086:
0087: public final static String APPLICATION_VERSION = VersionInfo
0088: .getVersion();
0089:
0090: public final static String GRUNTSPUD_HOME_PAGE_LOCATION = "http://gruntspud.sourceforge.net";
0091:
0092: private static boolean is14;
0093:
0094: private static URL gruntspudHomePage;
0095:
0096: private static GruntspudAuthenticator authenticator;
0097: static {
0098: UIUtil.cacheIcon(ICON_STATUS_NEEDS_ATTENTION,
0099: "images/overlay_subfolder_attention.png");
0100: UIUtil.cacheIcon(ICON_STATUS_MODULE_OVERLAY,
0101: "images/overlay_module.png");
0102: UIUtil.cacheIcon(ICON_STATUS_PROJECT_OVERLAY,
0103: "images/overlay_project.png");
0104: UIUtil.cacheIcon(ICON_STATUS_ERASED_OVERLAY,
0105: "images/overlay_erased.png");
0106: UIUtil.cacheIcon(ICON_STATUS_REMOVED_OVERLAY,
0107: "images/overlay_removed.png");
0108: UIUtil.cacheIcon(ICON_STATUS_ADDED_OVERLAY,
0109: "images/overlay_added.png");
0110: UIUtil.cacheIcon(ICON_STATUS_OUT_OF_DATE_OVERLAY,
0111: "images/overlay_out_of_date.png");
0112: UIUtil.cacheIcon(ICON_STATUS_IN_CVS_OVERLAY,
0113: "images/overlay_in_cvs.png");
0114: UIUtil.cacheIcon(ICON_STATUS_CONFLICTS_OVERLAY,
0115: "images/overlay_conflict.png");
0116: UIUtil.cacheIcon(ICON_STATUS_NEEDS_CHECKOUT_OVERLAY,
0117: "images/overlay_needs_checkout.png");
0118: UIUtil.cacheIcon(ICON_STATUS_NEEDS_MERGE_OVERLAY,
0119: "images/overlay_needs_merge.png");
0120: UIUtil.cacheIcon(ICON_STATUS_NEEDS_PATCH_OVERLAY,
0121: "images/overlay_needs_patch.png");
0122: UIUtil.cacheIcon(ICON_WINDOWS_LINE_ENDINGS,
0123: "images/overlay_windows_line_endings.png");
0124: UIUtil.cacheIcon(ICON_UNIX_LINE_ENDINGS,
0125: "images/overlay_unix_line_endings.png");
0126: UIUtil.cacheIcon(ICON_STATUS_ERASED, new OverlayIcon(UIUtil
0127: .getCachedIcon(ICON_STATUS_ERASED_OVERLAY), UIManager
0128: .getIcon("Tree.leafIcon"), SwingConstants.CENTER));
0129: UIUtil.cacheIcon(ICON_STATUS_REMOVED, new OverlayIcon(UIUtil
0130: .getCachedIcon(ICON_STATUS_REMOVED_OVERLAY), UIManager
0131: .getIcon("Tree.leafIcon"), SwingConstants.CENTER));
0132: UIUtil.cacheIcon(ICON_STATUS_ADDED, new OverlayIcon(UIUtil
0133: .getCachedIcon(ICON_STATUS_ADDED_OVERLAY), UIManager
0134: .getIcon("Tree.leafIcon"), SwingConstants.CENTER));
0135: UIUtil.cacheIcon(ICON_STATUS_OUT_OF_DATE, new OverlayIcon(
0136: UIUtil.getCachedIcon(ICON_STATUS_OUT_OF_DATE_OVERLAY),
0137: UIManager.getIcon("Tree.leafIcon"),
0138: SwingConstants.CENTER));
0139: UIUtil.cacheIcon(ICON_STATUS_CONFLICTS, new OverlayIcon(UIUtil
0140: .getCachedIcon(ICON_STATUS_CONFLICTS_OVERLAY),
0141: UIManager.getIcon("Tree.leafIcon"),
0142: SwingConstants.CENTER));
0143: UIUtil.cacheIcon(ICON_TYPE_BINARY, "images/type_binary.png");
0144: UIUtil.cacheIcon(ICON_TYPE_TEXT, "images/type_text.png");
0145: UIUtil.cacheIcon(ICON_TYPE_COPY, "images/type_copy.png");
0146: UIUtil.cacheIcon(ICON_TYPE_UNICODE, "images/type_unicode.png");
0147: UIUtil.cacheIcon(ICON_TYPE_IGNORE, "images/type_ignore.png");
0148: UIUtil.cacheIcon(ICON_TYPE_DIRECTORY,
0149: "images/type_directory.png");
0150: UIUtil.cacheIcon(ICON_TYPE_DEFAULT_LOCKER,
0151: "images/type_defaultLocker.png");
0152: UIUtil.cacheIcon(ICON_TYPE_OLD_VALUES,
0153: "images/type_oldValues.png");
0154: UIUtil.cacheIcon(ICON_TYPE_ONLY_KEYWORDS,
0155: "images/type_onlyKeywords.png");
0156: UIUtil.cacheIcon(ICON_TYPE_ONLY_VALUES,
0157: "images/type_onlyValues.png");
0158: UIUtil.cacheIcon(ICON_STATUS_ACTIVE, "images/greenledon.png");
0159: UIUtil.cacheIcon(ICON_STATUS_IDLE, "images/greenledoff.png");
0160: UIUtil.cacheIcon(ICON_STATUS_ERROR, "images/redledon.png");
0161: UIUtil
0162: .cacheIcon(ICON_TOOL_CHECKOUT,
0163: "images/tool_checkout.png");
0164: UIUtil.cacheIcon(ICON_TOOL_IMPORT, "images/tool_import.png");
0165: UIUtil.cacheIcon(ICON_TOOL_UPDATE, "images/tool_update.png");
0166: UIUtil.cacheIcon(ICON_TOOL_COMMIT, "images/tool_commit.png");
0167: UIUtil.cacheIcon(ICON_TOOL_ADD, "images/tool_add.png");
0168: UIUtil.cacheIcon(ICON_TOOL_REMOVE, "images/tool_remove.png");
0169: UIUtil.cacheIcon(ICON_TOOL_PREFERENCES,
0170: "images/tool_preferences.png");
0171: UIUtil.cacheIcon(ICON_TOOL_STATUS, "images/tool_status.png");
0172: UIUtil.cacheIcon(ICON_TOOL_HOME, "images/tool_home.png");
0173: UIUtil.cacheIcon(ICON_TOOL_UP, "images/tool_up.png");
0174: UIUtil.cacheIcon(ICON_TOOL_GO, "images/tool_go.png");
0175: UIUtil.cacheIcon(ICON_TOOL_BROWSE, "images/tool_browse.png");
0176: UIUtil.cacheIcon(ICON_TOOL_RELOAD, "images/tool_reload.png");
0177: UIUtil.cacheIcon(ICON_TOOL_STOP_COMMAND,
0178: "images/tool_stop_command.png");
0179: UIUtil.cacheIcon(ICON_TOOL_DIFF, "images/tool_diff.png");
0180: UIUtil.cacheIcon(ICON_TOOL_LOG, "images/tool_log.png");
0181: UIUtil.cacheIcon(ICON_TOOL_CUT, "images/tool_cut.png");
0182: UIUtil.cacheIcon(ICON_TOOL_COPY, "images/tool_copy.png");
0183: UIUtil.cacheIcon(ICON_TOOL_PASTE, "images/tool_paste.png");
0184: UIUtil.cacheIcon(ICON_TOOL_DELETE, "images/tool_delete.png");
0185: UIUtil.cacheIcon(ICON_TOOL_OPEN, "images/tool_open.png");
0186: UIUtil.cacheIcon(ICON_TOOL_SAVE, "images/tool_save.png");
0187: UIUtil.cacheIcon(ICON_TOOL_SAVE_AS, "images/tool_save_as.png");
0188: UIUtil.cacheIcon(ICON_TOOL_CONNECT, "images/tool_connect.png");
0189: UIUtil.cacheIcon(ICON_TOOL_NORMAL_ADD,
0190: "images/tool_normal_add.png");
0191: UIUtil.cacheIcon(ICON_TOOL_NORMAL_REMOVE,
0192: "images/tool_normal_remove.png");
0193: UIUtil.cacheIcon(ICON_TOOL_EDIT, "images/tool_edit.png");
0194: UIUtil.cacheIcon(ICON_TOOL_UNEDIT, "images/tool_unedit.png");
0195: UIUtil.cacheIcon(ICON_TOOL_EDITORS, "images/tool_editors.png");
0196: UIUtil.cacheIcon(ICON_TOOL_DEFAULT, "images/tool_default.png");
0197: UIUtil
0198: .cacheIcon(ICON_TOOL_MAINTAIN,
0199: "images/tool_maintain.png");
0200: UIUtil.cacheIcon(ICON_TOOL_CLEAR, "images/tool_new.png");
0201: UIUtil.cacheIcon(ICON_TOOL_LEFT, "images/tool_left.png");
0202: UIUtil.cacheIcon(ICON_TOOL_RIGHT, "images/tool_right.png");
0203: UIUtil.cacheIcon(ICON_TOOL_TOP, "images/tool_top.png");
0204: UIUtil.cacheIcon(ICON_TOOL_BOTTOM, "images/tool_bottom.png");
0205: UIUtil.cacheIcon(ICON_TOOL_OUTPUT,
0206: "images/tool_print_preview.png");
0207: UIUtil.cacheIcon(ICON_TOOL_COLOR, "images/tool_color.png");
0208: UIUtil.cacheIcon(ICON_TOOL_ERASE, "images/tool_delete.png");
0209: UIUtil.cacheIcon(ICON_TOOL_IGNORE, "images/tool_ignore.png");
0210: UIUtil.cacheIcon(ICON_TOOL_NEW_FOLDER,
0211: "images/tool_new_folder.png");
0212: UIUtil
0213: .cacheIcon(ICON_TOOL_NEW_FILE,
0214: "images/tool_new_file.png");
0215: UIUtil.cacheIcon(ICON_TOOL_HISTORY, "images/tool_history.png");
0216: UIUtil
0217: .cacheIcon(ICON_TOOL_ANNOTATE,
0218: "images/tool_annotate.png");
0219: UIUtil.cacheIcon(ICON_TOOL_EXIT, "images/tool_exit.png");
0220: UIUtil.cacheIcon(ICON_TOOL_TAG, "images/tool_tag.png");
0221: UIUtil.cacheIcon(ICON_TOOL_REMOVE_TAG,
0222: "images/tool_remove_tag.png");
0223: UIUtil.cacheIcon(ICON_TOOL_WATCH, "images/tool_watch.png");
0224: UIUtil
0225: .cacheIcon(ICON_TOOL_WATCHERS,
0226: "images/tool_watchers.png");
0227: UIUtil.cacheIcon(ICON_TOOL_LOGIN, "images/tool_connect.png");
0228: UIUtil
0229: .cacheIcon(ICON_TOOL_LOGOUT,
0230: "images/tool_disconnect.png");
0231: UIUtil.cacheIcon(ICON_TOOL_DETAILS, "images/tool_details.png");
0232: UIUtil.cacheIcon(ICON_TOOL_ABOUT, "images/tool_about.png");
0233: UIUtil.cacheIcon(ICON_TOOL_TOGGLE_FLAT_MODE,
0234: "images/tool_flat_mode.png");
0235: UIUtil.cacheIcon(ICON_TOOL_CLOSE_VIEW,
0236: "images/tool_close_view.png");
0237: UIUtil.cacheIcon(ICON_TOOL_FILTER, "images/tool_filter.png");
0238: UIUtil.cacheIcon(ICON_TOOL_HELP, "images/tool_help.png");
0239: UIUtil.cacheIcon(ICON_TOOL_WEB, "images/tool_web.png");
0240: UIUtil.cacheIcon(ICON_TOOL_VIEW_CVS, "images/tool_viewcvs.png");
0241: UIUtil.cacheIcon(ICON_TOOL_SEARCH, "images/tool_search.png");
0242: UIUtil
0243: .cacheIcon(ICON_TOOL_RETRIEVE,
0244: "images/tool_retrieve.png");
0245: UIUtil.cacheIcon(ICON_TOOL_TOGGLE_VIEW_DOCK,
0246: "images/tool_dock.png");
0247: UIUtil.cacheIcon(ICON_TOOL_RESOLVE, "images/tool_resolve.png");
0248: UIUtil.cacheIcon(ICON_TOOL_LOCK, "images/tool_lock.png");
0249: UIUtil.cacheIcon(ICON_TOOL_HOME_UP, "images/tool_home_up.png");
0250: UIUtil.cacheIcon(ICON_TOOL_HOME_GOTO,
0251: "images/tool_home_goto.png");
0252: UIUtil.cacheIcon(ICON_TOOL_HOME_BROWSE,
0253: "images/tool_home_browse.png");
0254: UIUtil.cacheIcon(ICON_TOOL_UNDO, "images/tool_undo.png");
0255: UIUtil.cacheIcon(ICON_TOOL_REDO, "images/tool_redo.png");
0256: UIUtil.cacheIcon(ICON_TOOL_SYSTEM, "images/tool_system.png");
0257: UIUtil.cacheIcon(ICON_TOOL_DISPLAY, "images/tool_display.png");
0258: UIUtil.cacheIcon(ICON_TOOL_GLOBAL, "images/tool_global.png");
0259: UIUtil.cacheIcon(ICON_TOOL_FILE_TYPES,
0260: "images/tool_filetypes.png");
0261: UIUtil.cacheIcon(ICON_TOOL_PLUGIN, "images/tool_plugin.png");
0262: UIUtil.cacheIcon(ICON_TOOL_INSTALL_PLUGIN,
0263: "images/tool_install_plugin.png");
0264: UIUtil.cacheIcon(ICON_TOOL_REMOVE_PLUGIN,
0265: "images/tool_remove_plugin.png");
0266: UIUtil.cacheIcon(ICON_TOOL_UPDATE_PLUGIN,
0267: "images/tool_update_plugin.png");
0268: UIUtil.cacheIcon(ICON_TOOL_CLOSE_ALL_VIEWS,
0269: "images/tool_close_all_views.png");
0270: UIUtil.cacheIcon(ICON_TOOL_PROJECT, "images/tool_project.png");
0271: UIUtil
0272: .cacheIcon(ICON_TOOL_PROJECTS,
0273: "images/tool_projects.png");
0274: UIUtil.cacheIcon(ICON_TOOL_ADD_AS_PROJECT,
0275: "images/tool_add_project.png");
0276: UIUtil.cacheIcon(ICON_TOOL_LARGE_REMOVE,
0277: "images/tool_large_remove.png");
0278: UIUtil.cacheIcon(ICON_TOOL_LARGE_COMMIT,
0279: "images/tool_large_commit.png");
0280: UIUtil.cacheIcon(ICON_TOOL_LARGE_CHECKOUT,
0281: "images/tool_large_checkout.png");
0282: UIUtil.cacheIcon(ICON_TOOL_LARGE_UPDATE,
0283: "images/tool_large_update.png");
0284: UIUtil.cacheIcon(ICON_TOOL_LARGE_ADD,
0285: "images/tool_large_add.png");
0286: UIUtil.cacheIcon(ICON_TOOL_LARGE_IMPORT,
0287: "images/tool_large_import.png");
0288: UIUtil.cacheIcon(ICON_TOOL_LARGE_PREFERENCES,
0289: "images/tool_large_preferences.png");
0290: UIUtil.cacheIcon(ICON_TOOL_LARGE_STOP_COMMAND,
0291: "images/tool_large_stop_command.png");
0292: UIUtil.cacheIcon(ICON_TOOL_LARGE_DIFF,
0293: "images/tool_large_diff.png");
0294: UIUtil.cacheIcon(ICON_TOOL_LARGE_LOG,
0295: "images/tool_large_log.png");
0296: UIUtil.cacheIcon(ICON_TOOL_LARGE_CONNECT,
0297: "images/tool_large_connect.png");
0298: UIUtil.cacheIcon(ICON_TOOL_LARGE_NORMAL_ADD,
0299: "images/tool_large_normal_add.png");
0300: UIUtil.cacheIcon(ICON_TOOL_LARGE_NORMAL_REMOVE,
0301: "images/tool_large_normal_remove.png");
0302: UIUtil.cacheIcon(ICON_TOOL_LARGE_EDIT,
0303: "images/tool_large_edit.png");
0304: UIUtil.cacheIcon(ICON_TOOL_LARGE_UNEDIT,
0305: "images/tool_large_unedit.png");
0306: UIUtil.cacheIcon(ICON_TOOL_LARGE_EDITORS,
0307: "images/tool_large_editors.png");
0308: UIUtil.cacheIcon(ICON_TOOL_LARGE_DEFAULT,
0309: "images/tool_large_default.png");
0310: UIUtil.cacheIcon(ICON_TOOL_LARGE_CLEAR,
0311: "images/tool_large_new.png");
0312: UIUtil.cacheIcon(ICON_TOOL_LARGE_MAINTAIN,
0313: "images/tool_large_maintain.png");
0314: UIUtil.cacheIcon(ICON_TOOL_LARGE_LEFT,
0315: "images/tool_large_left.png");
0316: UIUtil.cacheIcon(ICON_TOOL_LARGE_RIGHT,
0317: "images/tool_large_right.png");
0318: UIUtil.cacheIcon(ICON_TOOL_LARGE_TOP,
0319: "images/tool_large_top.png");
0320: UIUtil.cacheIcon(ICON_TOOL_LARGE_BOTTOM,
0321: "images/tool_large_bottom.png");
0322: UIUtil.cacheIcon(ICON_TOOL_LARGE_STATUS,
0323: "images/tool_large_status.png");
0324: UIUtil.cacheIcon(ICON_TOOL_LARGE_OUTPUT,
0325: "images/tool_large_print_preview.png");
0326: UIUtil.cacheIcon(ICON_TOOL_LARGE_COLOR,
0327: "images/tool_large_color.png");
0328: UIUtil.cacheIcon(ICON_TOOL_LARGE_DISPLAY,
0329: "images/tool_large_display.png");
0330: UIUtil.cacheIcon(ICON_TOOL_LARGE_ERASE,
0331: "images/tool_large_delete.png");
0332: UIUtil.cacheIcon(ICON_TOOL_LARGE_IGNORE,
0333: "images/tool_large_ignore.png");
0334: UIUtil.cacheIcon(ICON_TOOL_LARGE_NEW_FOLDER,
0335: "images/tool_large_new_folder.png");
0336: UIUtil.cacheIcon(ICON_TOOL_LARGE_NEW_FILE,
0337: "images/tool_large_new_file.png");
0338: UIUtil.cacheIcon(ICON_TOOL_LARGE_HISTORY,
0339: "images/tool_large_history.png");
0340: UIUtil.cacheIcon(ICON_TOOL_LARGE_ANNOTATE,
0341: "images/tool_large_annotate.png");
0342: UIUtil.cacheIcon(ICON_TOOL_LARGE_EXIT,
0343: "images/tool_large_exit.png");
0344: UIUtil.cacheIcon(ICON_TOOL_LARGE_TAG,
0345: "images/tool_large_tag.png");
0346: UIUtil.cacheIcon(ICON_TOOL_LARGE_REMOVE_TAG,
0347: "images/tool_large_remove_tag.png");
0348: UIUtil.cacheIcon(ICON_TOOL_LARGE_WATCH,
0349: "images/tool_large_watch.png");
0350: UIUtil.cacheIcon(ICON_TOOL_LARGE_WATCHERS,
0351: "images/tool_large_watchers.png");
0352: UIUtil.cacheIcon(ICON_TOOL_LARGE_LOGIN,
0353: "images/tool_large_connect.png");
0354: UIUtil.cacheIcon(ICON_TOOL_LARGE_LOGOUT,
0355: "images/tool_large_disconnect.png");
0356: UIUtil.cacheIcon(ICON_TOOL_LARGE_DETAILS,
0357: "images/tool_large_details.png");
0358: UIUtil.cacheIcon(ICON_TOOL_LARGE_TOGGLE_FLAT_MODE,
0359: "images/tool_large_flat_mode.png");
0360: UIUtil.cacheIcon(ICON_TOOL_LARGE_CLOSE_VIEW,
0361: "images/tool_large_close_view.png");
0362: UIUtil.cacheIcon(ICON_TOOL_LARGE_FILTER,
0363: "images/tool_large_filter.png");
0364: UIUtil.cacheIcon(ICON_TOOL_LARGE_HELP,
0365: "images/tool_large_help.png");
0366: UIUtil.cacheIcon(ICON_TOOL_LARGE_WEB,
0367: "images/tool_large_web.png");
0368: UIUtil.cacheIcon(ICON_TOOL_LARGE_VIEW_CVS,
0369: "images/tool_large_viewcvs.png");
0370: UIUtil.cacheIcon(ICON_TOOL_LARGE_SEARCH,
0371: "images/tool_large_search.png");
0372: UIUtil.cacheIcon(ICON_TOOL_LARGE_RETRIEVE,
0373: "images/tool_large_retrieve.png");
0374: UIUtil.cacheIcon(ICON_TOOL_LARGE_TOGGLE_VIEW_DOCK,
0375: "images/tool_large_dock.png");
0376: UIUtil.cacheIcon(ICON_TOOL_LARGE_SYSTEM,
0377: "images/tool_large_system.png");
0378: UIUtil.cacheIcon(ICON_TOOL_LARGE_RESOLVE,
0379: "images/tool_large_resolve.png");
0380: UIUtil.cacheIcon(ICON_TOOL_LARGE_LOCK,
0381: "images/tool_large_lock.png");
0382: UIUtil.cacheIcon(ICON_TOOL_LARGE_SERVER_IDENTITY,
0383: "images/tool_large_server_identity.png");
0384: UIUtil.cacheIcon(ICON_TOOL_LARGE_GLOBAL,
0385: "images/tool_large_global.png");
0386: UIUtil.cacheIcon(ICON_TOOL_LARGE_FILE_TYPES,
0387: "images/tool_large_filetypes.png");
0388: UIUtil.cacheIcon(ICON_TOOL_LARGE_PLUGIN,
0389: "images/tool_large_plugin.png");
0390: UIUtil.cacheIcon(ICON_TOOL_LARGE_INSTALL_PLUGIN,
0391: "images/tool_large_install_plugin.png");
0392: UIUtil.cacheIcon(ICON_TOOL_LARGE_REMOVE_PLUGIN,
0393: "images/tool_large_remove_plugin.png");
0394: UIUtil.cacheIcon(ICON_TOOL_LARGE_UPDATE_PLUGIN,
0395: "images/tool_large_update_plugin.png");
0396: UIUtil.cacheIcon(ICON_TOOL_LARGE_CLOSE_ALL_VIEWS,
0397: "images/tool_large_close_all_views.png");
0398: UIUtil.cacheIcon(ICON_TOOL_LARGE_PROJECTS,
0399: "images/tool_large_projects.png");
0400: UIUtil.cacheIcon(ICON_TOOL_LARGE_PROJECT,
0401: "images/tool_large_project.png");
0402: UIUtil.cacheIcon(ICON_TOOL_LARGE_ADD_AS_PROJECT,
0403: "images/tool_large_add_project.png");
0404: UIUtil.cacheIcon(ICON_TOOL_SMALL_ADD,
0405: "images/tool_small_add.png");
0406: UIUtil.cacheIcon(ICON_TOOL_SMALL_REMOVE,
0407: "images/tool_small_remove.png");
0408: UIUtil.cacheIcon(ICON_TOOL_SMALL_UPDATE,
0409: "images/tool_small_update.png");
0410: UIUtil.cacheIcon(ICON_TOOL_SMALL_COMMIT,
0411: "images/tool_small_commit.png");
0412: UIUtil.cacheIcon(ICON_TOOL_SMALL_CHECKOUT,
0413: "images/tool_small_checkout.png");
0414: UIUtil.cacheIcon(ICON_TOOL_SMALL_STATUS,
0415: "images/tool_small_status.png");
0416: UIUtil.cacheIcon(ICON_TOOL_SMALL_DIFF,
0417: "images/tool_small_diff.png");
0418: UIUtil.cacheIcon(ICON_TOOL_SMALL_CUT,
0419: "images/tool_small_cut.png");
0420: UIUtil.cacheIcon(ICON_TOOL_SMALL_COPY,
0421: "images/tool_small_copy.png");
0422: UIUtil.cacheIcon(ICON_TOOL_SMALL_PASTE,
0423: "images/tool_small_paste.png");
0424: UIUtil.cacheIcon(ICON_TOOL_SMALL_DELETE,
0425: "images/tool_small_delete.png");
0426: UIUtil.cacheIcon(ICON_TOOL_SMALL_LOG,
0427: "images/tool_small_log.png");
0428: UIUtil.cacheIcon(ICON_TOOL_SMALL_RELOAD,
0429: "images/tool_small_reload.png");
0430: UIUtil.cacheIcon(ICON_TOOL_SMALL_HOME,
0431: "images/tool_small_home.png");
0432: UIUtil
0433: .cacheIcon(ICON_TOOL_SMALL_UP,
0434: "images/tool_small_up.png");
0435: UIUtil.cacheIcon(ICON_TOOL_SMALL_CONNECT,
0436: "images/tool_small_connect.png");
0437: UIUtil.cacheIcon(ICON_TOOL_SMALL_PREFERENCES,
0438: "images/tool_small_preferences.png");
0439: UIUtil.cacheIcon(ICON_TOOL_SMALL_IMPORT,
0440: "images/tool_small_import.png");
0441: UIUtil.cacheIcon(ICON_TOOL_SMALL_ERASE,
0442: "images/tool_small_delete.png");
0443: UIUtil.cacheIcon(ICON_TOOL_SMALL_IGNORE,
0444: "images/tool_small_ignore.png");
0445: UIUtil.cacheIcon(ICON_TOOL_SMALL_NEW_FOLDER,
0446: "images/tool_small_new_folder.png");
0447: UIUtil.cacheIcon(ICON_TOOL_SMALL_NEW_FILE,
0448: "images/tool_small_new_file.png");
0449: UIUtil.cacheIcon(ICON_TOOL_SMALL_HISTORY,
0450: "images/tool_small_history.png");
0451: UIUtil.cacheIcon(ICON_TOOL_SMALL_ANNOTATE,
0452: "images/tool_small_annotate.png");
0453: UIUtil.cacheIcon(ICON_TOOL_SMALL_EXIT,
0454: "images/tool_small_exit.png");
0455: UIUtil.cacheIcon(ICON_TOOL_SMALL_TAG,
0456: "images/tool_small_tag.png");
0457: UIUtil.cacheIcon(ICON_TOOL_SMALL_REMOVE_TAG,
0458: "images/tool_small_remove_tag.png");
0459: UIUtil.cacheIcon(ICON_TOOL_SMALL_MAINTAIN,
0460: "images/tool_small_maintain.png");
0461: UIUtil.cacheIcon(ICON_TOOL_SMALL_NORMAL_REMOVE,
0462: "images/tool_small_normal_remove.png");
0463: UIUtil.cacheIcon(ICON_TOOL_SMALL_NORMAL_ADD,
0464: "images/tool_small_normal_add.png");
0465: UIUtil.cacheIcon(ICON_TOOL_SMALL_STOP_COMMAND,
0466: "images/tool_small_stop_command.png");
0467: UIUtil.cacheIcon(ICON_TOOL_SMALL_BROWSE,
0468: "images/tool_small_browse.png");
0469: UIUtil
0470: .cacheIcon(ICON_TOOL_SMALL_GO,
0471: "images/tool_small_go.png");
0472: UIUtil.cacheIcon(ICON_TOOL_SMALL_WATCH,
0473: "images/tool_small_watch.png");
0474: UIUtil.cacheIcon(ICON_TOOL_SMALL_WATCHERS,
0475: "images/tool_small_watchers.png");
0476: UIUtil.cacheIcon(ICON_TOOL_SMALL_LOGIN,
0477: "images/tool_small_connect.png");
0478: UIUtil.cacheIcon(ICON_TOOL_SMALL_LOGOUT,
0479: "images/tool_small_disconnect.png");
0480: UIUtil.cacheIcon(ICON_TOOL_SMALL_ABOUT,
0481: "images/tool_small_about.png");
0482: UIUtil.cacheIcon(ICON_TOOL_SMALL_EDIT,
0483: "images/tool_small_edit.png");
0484: UIUtil.cacheIcon(ICON_TOOL_SMALL_UNEDIT,
0485: "images/tool_small_unedit.png");
0486: UIUtil.cacheIcon(ICON_TOOL_SMALL_EDITORS,
0487: "images/tool_small_editors.png");
0488: UIUtil.cacheIcon(ICON_TOOL_SMALL_DETAILS,
0489: "images/tool_small_details.png");
0490: UIUtil.cacheIcon(ICON_TOOL_SMALL_TOGGLE_FLAT_MODE,
0491: "images/tool_small_flat_mode.png");
0492: UIUtil.cacheIcon(ICON_TOOL_SMALL_CLOSE_VIEW,
0493: "images/tool_small_close_view.png");
0494: UIUtil.cacheIcon(ICON_TOOL_SMALL_FILTER,
0495: "images/tool_small_filter.png");
0496: UIUtil.cacheIcon(ICON_TOOL_SMALL_HELP,
0497: "images/tool_small_help.png");
0498: UIUtil.cacheIcon(ICON_TOOL_SMALL_WEB,
0499: "images/tool_small_web.png");
0500: UIUtil.cacheIcon(ICON_TOOL_SMALL_VIEW_CVS,
0501: "images/tool_small_viewcvs.png");
0502: UIUtil.cacheIcon(ICON_TOOL_SMALL_DEFAULT,
0503: "images/tool_small_default.png");
0504: UIUtil.cacheIcon(ICON_TOOL_SMALL_SEARCH,
0505: "images/tool_small_search.png");
0506: UIUtil.cacheIcon(ICON_TOOL_SMALL_RETRIEVE,
0507: "images/tool_small_retrieve.png");
0508: UIUtil.cacheIcon(ICON_TOOL_SMALL_TOGGLE_VIEW_DOCK,
0509: "images/tool_small_dock.png");
0510: UIUtil.cacheIcon(ICON_TOOL_SMALL_RESOLVE,
0511: "images/tool_small_resolve.png");
0512: UIUtil.cacheIcon(ICON_TOOL_SMALL_LOCK,
0513: "images/tool_small_lock.png");
0514: UIUtil.cacheIcon(ICON_TOOL_SMALL_SAVE,
0515: "images/tool_small_save.png");
0516: UIUtil.cacheIcon(ICON_TOOL_SMALL_HOME_UP,
0517: "images/tool_small_home_up.png");
0518: UIUtil.cacheIcon(ICON_TOOL_SMALL_HOME_GOTO,
0519: "images/tool_small_home_goto.png");
0520: UIUtil.cacheIcon(ICON_TOOL_SMALL_HOME_BROWSE,
0521: "images/tool_small_home_browse.png");
0522: UIUtil.cacheIcon(ICON_TOOL_SMALL_SYSTEM,
0523: "images/tool_small_system.png");
0524: UIUtil.cacheIcon(ICON_TOOL_SMALL_DISPLAY,
0525: "images/tool_small_display.png");
0526: UIUtil.cacheIcon(ICON_TOOL_SMALL_GLOBAL,
0527: "images/tool_small_global.png");
0528: UIUtil.cacheIcon(ICON_TOOL_SMALL_FILE_TYPES,
0529: "images/tool_small_filetypes.png");
0530: UIUtil.cacheIcon(ICON_TOOL_SMALL_PLUGIN,
0531: "images/tool_small_plugin.png");
0532: UIUtil.cacheIcon(ICON_TOOL_SMALL_INSTALL_PLUGIN,
0533: "images/tool_small_install_plugin.png");
0534: UIUtil.cacheIcon(ICON_TOOL_SMALL_REMOVE_PLUGIN,
0535: "images/tool_small_remove_plugin.png");
0536: UIUtil.cacheIcon(ICON_TOOL_SMALL_UPDATE_PLUGIN,
0537: "images/tool_small_update_plugin.png");
0538: UIUtil.cacheIcon(ICON_TOOL_SMALL_CLOSE_ALL_VIEWS,
0539: "images/tool_small_close_all_views.png");
0540: UIUtil.cacheIcon(ICON_TOOL_SMALL_PROJECTS,
0541: "images/tool_small_projects.png");
0542: UIUtil.cacheIcon(ICON_TOOL_SMALL_PROJECT,
0543: "images/tool_small_project.png");
0544: UIUtil.cacheIcon(ICON_TOOL_SMALL_ADD_AS_PROJECT,
0545: "images/tool_small_add_project.png");
0546: UIUtil.cacheIcon(GRUNTSPUD_LOGO, "images/gruntspud.png");
0547: UIUtil
0548: .cacheIcon(GRUNTSPUD_LOGO_ANIMATION,
0549: "images/anifish.gif");
0550: UIUtil.cacheIcon(GRUNTSPUD_LOGO_STATIC, "images/fish.gif");
0551: is14 = System.getProperty("java.version").startsWith("1.4");
0552: }
0553: static {
0554: try {
0555: gruntspudHomePage = new URL(GRUNTSPUD_HOME_PAGE_LOCATION);
0556: } catch (MalformedURLException murle) {
0557: }
0558: }
0559:
0560: // Private instance variables
0561: private CVSFileNodeTree tree;
0562:
0563: private boolean floating;
0564:
0565: private CVSFileNode homeNode;
0566:
0567: private StatusLabel cvsRootLabel;
0568:
0569: private CVSFileNodeTable fileNodeTable;
0570:
0571: private boolean adjusting;
0572:
0573: private CVSFileFilterPane filterPane;
0574:
0575: // private BasicListener cvsListener;
0576: private GlobalOptions globalOptions;
0577: private GruntspudHost host;
0578: private File home;
0579: private JSplitPane accessorySplit;
0580: private GruntspudContext context;
0581: private JPopupMenu popup;
0582: private JSplitPane split;
0583: private JToolBar buttons;
0584: private JMenu openMenu;
0585: private boolean pluginManagerStarted;
0586:
0587: /**
0588: * Construct a new instance of Gruntspud. An implementation of
0589: * <code>GruntspudHost</code> must be provided to provide required services,
0590: * such as a preferences backend.
0591: *
0592: * @param host host implementation
0593: */
0594: public Gruntspud(GruntspudHost host) {
0595: // If enabled, log all CVS output to GRUNTSPUD.in and GRUNTSPUD.out in
0596: // the users home directory
0597: if (host.getBooleanProperty(
0598: Constants.OPTIONS_SYSTEM_LOG_CVS_IO, false)) {
0599: Logger.setLogging(System.getProperty("user.home")
0600: + File.separator + "GRUNTSPUD");
0601: // Its a cheat i know but it seems to always work ok
0602: }
0603: System
0604: .setProperty("javacvs.multiple_commands_warning",
0605: "false");
0606: //
0607: this .host = host;
0608: System
0609: .setProperty(
0610: "gruntspud.hideMenuIcons",
0611: String
0612: .valueOf(host
0613: .getBooleanProperty(
0614: Constants.OPTIONS_SYSTEM_HIDE_MENU_ICONS,
0615: false)));
0616: System
0617: .setProperty(
0618: "gruntspud.disableKeyboardAccelerators",
0619: String
0620: .valueOf(host
0621: .getBooleanProperty(
0622: Constants.OPTIONS_SYSTEM_DISABLE_KEYBOARD_ACCELERATORS,
0623: false)));
0624: // Context
0625: context = new DefaultGruntspudContext(host);
0626: context.getViewManager().start(context);
0627: }
0628:
0629: public void start() throws Exception {
0630: if (!host.getBooleanProperty(Constants.LICENSE_ACCEPTED, false)) {
0631: LicensePanel licensePanel = new LicensePanel();
0632: String[] licenseResources = { "/LICENSE.txt",
0633: "/NETCOMPONENTS_LICENSE.txt",
0634: "/PLUGSPUD_LICENSE.txt", "/SPL_LICENSE.txt" };
0635: for (int i = 0; i < licenseResources.length; i++) {
0636: try {
0637: URL resource = getClass().getResource(
0638: licenseResources[i]);
0639: licensePanel.addLicenseText(resource);
0640: } catch (Exception e) {
0641: Constants.UI_LOG.error(e);
0642: }
0643: }
0644: if (!licensePanel.showLicense(this )) {
0645: throw new Exception("License rejected");
0646: }
0647: host.setBooleanProperty(Constants.LICENSE_ACCEPTED, true);
0648: }
0649:
0650: context.getPluginManager().start();//
0651: // Disable keyboard accelerators?
0652: // Enabled logging to the console if required
0653: if (host.getBooleanProperty(
0654: Constants.OPTIONS_SYSTEM_DEBUG_TO_CONSOLE, false)) {
0655: org.apache.log4j.Logger.getRootLogger().addAppender(
0656: new GruntspudConsoleAppender());
0657: // Are there connection profiles?
0658: }
0659: if (context.getConnectionProfileModel().getRowCount() == 0) {
0660: TellMeAgainPane
0661: .showTellMeAgainDialog(
0662: context,
0663: this ,
0664: "Warn me about this again",
0665: Constants.MESSAGE_WARN_ABOUT_NO_CONNECTION_PROFILES,
0666: "Gruntspud currently has no connection profiles\n"
0667: + "configured. Before you can use any remote cvs\n"
0668: + "commands, you must set one connection profile\n"
0669: + "for each CVSROOT that you wish use. You can\n"
0670: + "find connection profiles in the preferences\n"
0671: + "dialog.",
0672: "No connection profiles",
0673: UIUtil
0674: .getCachedIcon(Constants.ICON_TOOL_LARGE_CONNECT));
0675: // Listen for changes in where the tool bar is
0676: }
0677: addContainerListener(new ContainerAdapter() {
0678: public void componentAdded(ContainerEvent e) {
0679: if (Gruntspud.this .isShowing()) {
0680: // Need to be on event dispatch thread as event order seems to have
0681: // changed??
0682: SwingUtilities.invokeLater(new Runnable() {
0683: public void run() {
0684: Gruntspud.this .host.setProperty(
0685: Constants.TOOL_BAR_POSITION, UIUtil
0686: .getToolBarPosition(
0687: buttons,
0688: Gruntspud.this ));
0689: }
0690: });
0691: }
0692: }
0693: });
0694: }
0695:
0696: /**
0697: * DOCUMENT ME!
0698: *
0699: * @param viz DOCUMENT ME!
0700: */
0701: public void setToolBarVisible(boolean viz) {
0702: buttons.setVisible(viz);
0703: }
0704:
0705: /**
0706: * DOCUMENT ME!
0707: *
0708: * @return DOCUMENT ME!
0709: */
0710: public static GruntspudAuthenticator getAuthenticator() {
0711: return authenticator;
0712: }
0713:
0714: /**
0715: * DOCUMENT ME!
0716: *
0717: * @return DOCUMENT ME!
0718: */
0719: public static URL getHomePage() {
0720: return gruntspudHomePage;
0721: }
0722:
0723: /**
0724: * DOCUMENT ME!
0725: */
0726: public void init() {
0727: //
0728: context.getViewManager().reset();
0729: boolean showSelectiveText = context.getHost()
0730: .getBooleanProperty(
0731: Constants.TOOL_BAR_SHOW_SELECTIVE_TEXT, true);
0732: // Tool bar
0733: String buttonsPosition = host.getProperty(
0734: Constants.TOOL_BAR_POSITION, BorderLayout.NORTH);
0735: buttons = new JToolBar("Gruntspud Tools", (buttonsPosition
0736: .equals(BorderLayout.NORTH) || buttonsPosition
0737: .equals(BorderLayout.SOUTH)) ? JToolBar.HORIZONTAL
0738: : JToolBar.VERTICAL);
0739: buttons.setFloatable(true);
0740: buttons.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
0741: //
0742: boolean smallIcon = host.getBooleanProperty(
0743: Constants.TOOL_BAR_SMALL_ICONS, false);
0744: String actions = host.getProperty(Constants.TOOL_BAR_ACTIONS,
0745: Constants.TOOL_BAR_DEFAULT_ACTIONS);
0746: StringTokenizer t = new StringTokenizer(actions, ",");
0747: while (t.hasMoreTokens()) {
0748: String z = t.nextToken();
0749: if (z.equals(Constants.TOOL_BAR_SEPARATOR)) {
0750: buttons.add(new ToolBarSeparator());
0751: } else {
0752: Action a = getContext().getViewManager().getAction(z);
0753: if (a == null) {
0754: Constants.UI_LOG
0755: .warn("The action '"
0756: + z
0757: + "' that was on the toolbar "
0758: + "can no longer be found. This may be due to the removal "
0759: + "of a plugin or it is a core action that is no longer "
0760: + "valid.");
0761: } else {
0762: buttons.add(UIUtil.createButton(a,
0763: showSelectiveText, smallIcon));
0764: }
0765: }
0766: }
0767: //
0768: JPanel upper = new JPanel(new GridBagLayout());
0769: GridBagConstraints gbc = new GridBagConstraints();
0770: gbc.fill = GridBagConstraints.HORIZONTAL;
0771: gbc.anchor = GridBagConstraints.CENTER;
0772: gbc.weightx = 1.0;
0773: UIUtil.jGridBagAdd(upper, context.getViewManager()
0774: .getHomeLocationComponent(), gbc,
0775: GridBagConstraints.REMAINDER);
0776: gbc.insets = new Insets(2, 0, 0, 0);
0777: UIUtil.jGridBagAdd(upper,
0778: new JSeparator(JSeparator.HORIZONTAL), gbc,
0779: GridBagConstraints.REMAINDER);
0780: //
0781: JPanel main = new JPanel(new BorderLayout());
0782: main.add(upper, BorderLayout.NORTH);
0783: main.add(context.getViewManager(), BorderLayout.CENTER);
0784: // file read only handler
0785: setHandlers();
0786: removeAll();
0787: setLayout(new BorderLayout());
0788: add(buttons, buttonsPosition);
0789: // If this host has an accessory component, then add a split pane
0790: // containing that main view and the accessory component
0791: JComponent accessory = host.getAccessoryComponent();
0792: if (accessory != null) {
0793: accessorySplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
0794: false, main, accessory);
0795: accessorySplit.setResizeWeight(0.9d);
0796: accessorySplit.setDividerSize(9);
0797: accessorySplit.setOneTouchExpandable(true);
0798: if (host.getIntegerProperty(
0799: Constants.SPLIT_ACCESSORY_DIVIDER_LOCATION, -1) == -1) {
0800: accessorySplit.setDividerLocation(0.75d);
0801: } else {
0802: accessorySplit
0803: .setDividerLocation(host
0804: .getIntegerProperty(Constants.SPLIT_ACCESSORY_DIVIDER_LOCATION));
0805: }
0806: add(accessorySplit, BorderLayout.CENTER);
0807: }
0808: // Otherwise just the normal view with split pane
0809: else {
0810: accessorySplit = null;
0811: add(main, BorderLayout.CENTER);
0812: }
0813: revalidate();
0814: // Set the authenticator
0815: try {
0816: authenticator = new GruntspudAuthenticator(context);
0817: Authenticator.setDefault(authenticator);
0818: authenticator.init(context);
0819: } catch (IOException ioe) {
0820: GruntspudUtil.showErrorMessage(this , "Error", ioe);
0821: }
0822: }
0823:
0824: /**
0825: * @param f Description of the Parameter
0826: * @exception IOException Description of the Exception
0827: */
0828: public GruntspudContext getContext() {
0829: return context;
0830: }
0831:
0832: public void updateUI() {
0833: super .updateUI();
0834: if (buttons != null)
0835: buttons.updateUI();
0836: }
0837:
0838: /**
0839: * DOCUMENT ME!
0840: */
0841: public void cleanUp() {
0842: context.cleanUp();
0843: if (accessorySplit != null) {
0844: host.setIntegerProperty(
0845: Constants.SPLIT_ACCESSORY_DIVIDER_LOCATION,
0846: accessorySplit.getDividerLocation());
0847: }
0848: }
0849:
0850: private void setHandlers() {
0851: /* these OS names came from http://www.tolstoy.com/samizdat/sysprops.html */
0852: FileReadOnlyHandler handler = null;
0853: FileModeHandler modeHandler = null;
0854: if (!host
0855: .getBooleanProperty(
0856: Constants.OPTIONS_SYSTEM_DISABLE_NATIVE_PERMISSION_HANDLER,
0857: false)) {
0858: String osName = System.getProperty("os.name", "UNKNOWN");
0859: if (osName.toLowerCase().startsWith("windows")
0860: || osName.toLowerCase().startsWith("os/2")) {
0861: handler = new WindowsFileReadOnlyHandler();
0862: Constants.SYSTEM_LOG
0863: .info("Using ATTRIB command to set read only attribute on files.");
0864: } else if (osName.equalsIgnoreCase("linux")
0865: || osName.equalsIgnoreCase("solaris")
0866: || osName.equalsIgnoreCase("SunOS")
0867: || osName.equalsIgnoreCase("mpe/ix")
0868: || osName.equalsIgnoreCase("hp-ux")
0869: || osName.equalsIgnoreCase("aix")
0870: || osName.equalsIgnoreCase("freebsd")
0871: || osName.equalsIgnoreCase("irix")
0872: || osName.equalsIgnoreCase("digital unix")
0873: ||
0874: // these two are a bit of a stab in the dark - need some feedback
0875: osName.equalsIgnoreCase("darwin")
0876: || osName.equalsIgnoreCase("mac os x")) {
0877: handler = new ChmodFileReadOnlyHandler();
0878: Constants.SYSTEM_LOG
0879: .info("Using chmod command to set file attributes.");
0880: modeHandler = new UnixFileModeHandler();
0881: }
0882: // No handlers
0883: if (handler == null) {
0884: JOptionPane
0885: .showMessageDialog(
0886: this ,
0887: "No command to use for this platform. Please submit a feature "
0888: + "request detailing the platform you use and the command "
0889: + "you would normally use to set a file to be read only.",
0890: "No read only command available",
0891: JOptionPane.WARNING_MESSAGE);
0892: } else {
0893: FileUtils.setFileReadOnlyHandler(handler);
0894: // If there is a file mode handler to use, register it. This will be
0895: // used
0896: // in preference to the read only handler
0897: }
0898: if (modeHandler != null) {
0899: GruntspudFileUtils.setFileModeHandler(modeHandler);
0900: }
0901: } else {
0902: Constants.SYSTEM_LOG
0903: .info("Using Java to set file permissions.");
0904: }
0905: }
0906:
0907: /**
0908: * Description of the Method
0909: *
0910: * @param commandString Description of the Parameter
0911: */
0912: public void runCommand(String commandString) {
0913: Vector arguments = new Vector();
0914: boolean inDoubleQuote = false;
0915: boolean inSingleQuote = false;
0916: boolean escaped = false;
0917: StringBuffer buf = new StringBuffer();
0918: for (int i = 0; i < commandString.length(); i++) {
0919: char ch = commandString.charAt(i);
0920: if ((ch == '\\') && !escaped && !inSingleQuote) {
0921: escaped = true;
0922: } else if ((ch == '\'') && !inDoubleQuote && !escaped) {
0923: inSingleQuote = !inSingleQuote;
0924: } else if ((ch == '"') && !inDoubleQuote && !escaped) {
0925: inDoubleQuote = !inDoubleQuote;
0926: } else if ((ch == ' ') && !inDoubleQuote && !inSingleQuote
0927: && !escaped) {
0928: arguments.addElement(buf.toString());
0929: buf.setLength(0);
0930: } else {
0931: buf.append(ch);
0932: }
0933: }
0934: if (buf.length() != 0) {
0935: arguments.addElement(buf.toString());
0936: }
0937: String[] args = new String[arguments.size()];
0938: arguments.copyInto(args);
0939: runCommand(args);
0940: }
0941:
0942: /**
0943: * Description of the Method
0944: *
0945: * @param arguments Description of the Parameter
0946: * @param node Description of the Parameter
0947: */
0948: private void cvs(String[] arguments, CVSFileNode node) {
0949: }
0950:
0951: /**
0952: * Description of the Method
0953: *
0954: * @param arguments Description of the Parameter
0955: * @exception IllegalArgumentException Description of the Exception
0956: */
0957: private void cd(String[] arguments) throws IllegalArgumentException {
0958: CVSFileNode node = null;
0959: if (arguments.length == 0) {
0960: node = (CVSFileNode) tree.getModel().getRoot();
0961: } else if (arguments[0].equals("/")) {
0962: node = (CVSFileNode) tree.getModel().getRoot();
0963: } else if (arguments[0].equals("..")
0964: && (fileNodeTable.getRootNode().getParent() != null)) {
0965: node = (CVSFileNode) fileNodeTable.getRootNode()
0966: .getParent();
0967: } else {
0968: CVSFileNode base = arguments[0].startsWith("/") ? (CVSFileNode) tree
0969: .getModel().getRoot()
0970: : fileNodeTable.getRootNode();
0971: StringTokenizer t = new StringTokenizer(arguments[0], "/");
0972: CVSFileNode current = base;
0973: boolean found = false;
0974: while (t.hasMoreTokens()) {
0975: String s = t.nextToken();
0976: found = false;
0977: if (s.length() != 0) {
0978: for (int i = 0; (i < current.getChildCount())
0979: && !found; i++) {
0980: CVSFileNode z = (CVSFileNode) current
0981: .getChildAt(i);
0982: if (z.getName().equals(s)) {
0983: found = true;
0984: current = z;
0985: }
0986: }
0987: if (!found) {
0988: break;
0989: }
0990: }
0991: }
0992: if (found) {
0993: node = current;
0994: }
0995: }
0996: if (node == null) {
0997: throw new IllegalArgumentException("No such directory.");
0998: }
0999: context.getViewManager().setSelectedNode(node);
1000: }
1001:
1002: /**
1003: * Description of the Method
1004: *
1005: * @param command Description of the Parameter
1006: */
1007: public void runCommand(String[] command) {
1008: try {
1009: if (command.length == 0) {
1010: throw new IllegalArgumentException();
1011: }
1012: String cmd = command[0];
1013: String[] arguments = new String[command.length - 1];
1014: System
1015: .arraycopy(command, 1, arguments, 0,
1016: arguments.length);
1017: if (cmd.equalsIgnoreCase("cd")) {
1018: cd(arguments);
1019: } else if (cmd.equalsIgnoreCase("cvs")) {
1020: cvs(arguments, fileNodeTable.getRootNode());
1021: } else {
1022: throw new IllegalArgumentException("No such command.");
1023: }
1024: } catch (IllegalArgumentException ie) {
1025: context.getHost().showException(ie, "Command failed");
1026: }
1027: }
1028:
1029: /**
1030: * Description of the Method
1031: */
1032: private void openSelectedFile() {
1033: CVSFileNode sel = tree.getSelectedFileNode();
1034: if ((sel != null) && (sel.getFile() != null) && sel.isLeaf()) {
1035: context.openNode(sel, FileTypeMapping.OPEN_USING_DEFAULT);
1036: }
1037: }
1038:
1039: /**
1040: * Description of the Method
1041: *
1042: * @param parent Description of the Parameter
1043: * @param modal Description of the Parameter
1044: * @param title Description of the Parameter
1045: * @return Description of the Return Value
1046: */
1047: public static JDialog createDialog(Component parent, boolean modal,
1048: String title) {
1049: JDialog d = null;
1050: Window w = SwingUtilities.getWindowAncestor(parent);
1051: if (parent == null) {
1052: return null;
1053: }
1054: if (w instanceof Dialog) {
1055: d = new JDialog((Dialog) w, title, modal);
1056: } else if (w instanceof Frame) {
1057: d = new JDialog((Frame) w, title, modal);
1058: } else {
1059: d = new JDialog((Frame) null, title, modal);
1060: ;
1061: }
1062: return d;
1063: }
1064:
1065: /**
1066: * Return if this is a 1.4 runtime
1067: *
1068: * @return is a 1.4 runtime
1069: */
1070: public static boolean is14() {
1071: return is14;
1072: }
1073:
1074: // Statics
1075: // Supporting classes
1076: class StatusLabel extends JLabel {
1077: private int width;
1078:
1079: /**
1080: * Constructor for the StatusLabel object
1081: *
1082: * @param width Description of the Parameter
1083: */
1084: public StatusLabel(int width) {
1085: super (" ");
1086: setBorder(BorderFactory.createLoweredBevelBorder());
1087: this .width = width;
1088: }
1089:
1090: public Dimension getPreferredSize() {
1091: FontMetrics fm = javax.swing.text.StyleContext
1092: .getDefaultStyleContext().getFontMetrics(getFont());
1093: return new Dimension((fm.stringWidth("W") * width) + 4,
1094: super .getPreferredSize().height);
1095: }
1096: }
1097:
1098: class CVSFileNodeWrapper implements Comparable {
1099: CVSFileNode node;
1100:
1101: /**
1102: * Constructor for the CVSFileNodeWrapper object
1103: *
1104: * @param node Description of the Parameter
1105: */
1106: CVSFileNodeWrapper(CVSFileNode node) {
1107: this .node = node;
1108: }
1109:
1110: public int compareTo(Object o) {
1111: CVSFileNode other = ((CVSFileNodeWrapper) o).node;
1112: int i = node.getFile().getParent().compareTo(
1113: other.getFile().getParent());
1114: if (i == 0) {
1115: i = node.getCVSSubstType().getName().compareTo(
1116: other.getCVSSubstType().getName());
1117: if (i == 0) {
1118: return node.getName().compareTo(other.getName());
1119: } else {
1120: return i;
1121: }
1122: } else {
1123: return i;
1124: }
1125: }
1126: }
1127:
1128: // class BasicListener extends CVSAdapter
1129: // {
1130: // private final StringBuffer taggedLine = new StringBuffer();
1131: //
1132: // public void messageSent(MessageEvent evt)
1133: // {
1134: // String line = evt.getMessage();
1135: // Color c = evt.isError() ? Color.red :
1136: // Color.blue.darker();
1137: // if (evt.isTagged())
1138: // {
1139: // String message = evt.parseTaggedMessage(taggedLine, evt.getMessage());
1140: // if (message != null)
1141: // {
1142: // host.writeToConsole(c, message);
1143: // }
1144: // }
1145: // else
1146: // {
1147: // host.writeToConsole(c, line);
1148: // }
1149: // }
1150: // }
1151: class GruntspudConsoleAppender extends
1152: org.apache.log4j.AppenderSkeleton {
1153: public boolean requiresLayout() {
1154: return false;
1155: }
1156:
1157: public void close() {
1158: }
1159:
1160: public void append(org.apache.log4j.spi.LoggingEvent le) {
1161: if (context != null) {
1162: host.writeToConsole(context.getTextStyleModel()
1163: .getStyle(Constants.OPTIONS_STYLE_GRUNTSPUD),
1164: String.valueOf(le.getMessage()));
1165: }
1166: }
1167: }
1168: }
|