@Override public boolean handles(URIish uri) { if (getDefaultScheme().equals(uri.getScheme())) return true; if (uri.getHost() != null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getPath() == null) return false; if (uri.getScheme() == null) return FS.DETECTED.resolve(new File("."), uri.getPath()).isDirectory(); // $NON-NLS-1$ return false; }
/** This method initializes the plugin preferences with default values. */ public void initializeDefaultPreferences() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); int[] w; store.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_RELATIVE_DATE, true); store.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_EMAIL_ADDRESSES, false); store.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_NOTES, false); store.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP, true); store.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_REV_DETAIL, true); store.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_REV_COMMENT, true); store.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_TOOLTIPS, false); store.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_ALL_BRANCHES, false); store.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_ADDITIONAL_REFS, true); store.setDefault(UIPreferences.RESOURCEHISTORY_FOLLOW_RENAMES, true); store.setDefault(UIPreferences.RESOURCEHISTORY_COMPARE_MODE, false); store.setDefault(UIPreferences.DECORATOR_RECOMPUTE_ANCESTORS, true); store.setDefault( UIPreferences.DECORATOR_FILETEXT_DECORATION, GitLightweightDecorator.DecorationHelper.FILE_FORMAT_DEFAULT); store.setDefault( UIPreferences.DECORATOR_FOLDERTEXT_DECORATION, GitLightweightDecorator.DecorationHelper.FOLDER_FORMAT_DEFAULT); store.setDefault( UIPreferences.DECORATOR_PROJECTTEXT_DECORATION, GitLightweightDecorator.DecorationHelper.PROJECT_FORMAT_DEFAULT); store.setDefault(UIPreferences.DECORATOR_SHOW_TRACKED_ICON, true); store.setDefault(UIPreferences.DECORATOR_SHOW_UNTRACKED_ICON, true); store.setDefault(UIPreferences.DECORATOR_SHOW_STAGED_ICON, true); store.setDefault(UIPreferences.DECORATOR_SHOW_CONFLICTS_ICON, true); store.setDefault(UIPreferences.DECORATOR_SHOW_ASSUME_VALID_ICON, true); store.setDefault(UIPreferences.DECORATOR_SHOW_DIRTY_ICON, false); w = new int[] {500, 500}; store.setDefault(UIPreferences.RESOURCEHISTORY_GRAPH_SPLIT, UIPreferences.intArrayToString(w)); w = new int[] {700, 300}; store.setDefault(UIPreferences.RESOURCEHISTORY_REV_SPLIT, UIPreferences.intArrayToString(w)); store.setDefault(UIPreferences.FINDTOOLBAR_IGNORE_CASE, true); store.setDefault(UIPreferences.FINDTOOLBAR_FIND_IN, FindToolbar.PREFS_FINDIN_ALL); store.setDefault(UIPreferences.COMMIT_DIALOG_HARD_WRAP_MESSAGE, true); store.setDefault(UIPreferences.COMMIT_DIALOG_SIGNED_OFF_BY, false); store.setDefault(UIPreferences.REFESH_ON_INDEX_CHANGE, true); store.setDefault(UIPreferences.REFESH_ONLY_WHEN_ACTIVE, true); store.setDefault( UIPreferences.DEFAULT_REPO_DIR, new File(FS.DETECTED.userHome(), "git").getPath()); // $NON-NLS-1$ store.setDefault(UIPreferences.SHOW_REBASE_CONFIRM, true); store.setDefault(UIPreferences.SHOW_INITIAL_CONFIG_DIALOG, true); store.setDefault(UIPreferences.SHOW_HOME_DIR_WARNING, true); store.setDefault(UIPreferences.SHOW_GIT_PREFIX_WARNING, true); store.setDefault(UIPreferences.SHOW_DETACHED_HEAD_WARNING, true); store.setDefault(UIPreferences.SHOW_CHECKOUT_CONFIRMATION, true); store.setDefault( UIPreferences.SYNC_VIEW_CHANGESET_LABEL_FORMAT, UIPreferences.DEFAULT_CHANGESET_FORMAT); store.setDefault(UIPreferences.SYNC_VIEW_ALWAYS_SHOW_CHANGESET_MODEL, false); store.setDefault(UIPreferences.SYNC_VIEW_FETCH_BEFORE_LAUNCH, true); store.setDefault(UIPreferences.DATE_FORMAT, UIPreferences.DEFAULT_DATE_FORMAT); store.setDefault(UIPreferences.HISTORY_MAX_NUM_COMMITS, 10000); store.setDefault(UIPreferences.HISTORY_SHOW_TAG_SEQUENCE, false); store.setDefault(UIPreferences.BLAME_IGNORE_WHITESPACE, false); store.setDefault(UIPreferences.REMOTE_CONNECTION_TIMEOUT, 30 /* seconds */); store.setDefault(UIPreferences.STAGING_VIEW_PRESENTATION, StagingView.Presentation.LIST.name()); store.setDefault(UIPreferences.STAGING_VIEW_FILENAME_MODE, true); store.setDefault(UIPreferences.CLONE_WIZARD_STORE_SECURESTORE, false); store.setDefault(UIPreferences.COMMIT_DIALOG_HISTORY_SIZE, 10); store.setDefault(UIPreferences.CHECKOUT_PROJECT_RESTORE, true); store.setDefault(UIPreferences.HISTORY_MAX_TAG_LENGTH, 18); store.setDefault(UIPreferences.HISTORY_MAX_BRANCH_LENGTH, 18); store.setDefault(UIPreferences.CLONE_WIZARD_SHOW_DETAILED_FAILURE_DIALOG, true); store.setDefault(UIPreferences.MERGE_MODE, "2"); // $NON-NLS-1$ }
/** Check the user input and set messages in case of invalid input. */ protected void checkPage() { if (isURISelected()) { assert uri != null; if (uriText.getText().length() == 0) { selectionIncomplete(null); return; } else if (uriText.getText().endsWith(" ")) { // $NON-NLS-1$ selectionIncomplete(UIText.RepositorySelectionPage_UriMustNotHaveTrailingSpacesMessage); return; } try { final URIish finalURI = new URIish(uriText.getText().trim()); String proto = finalURI.getScheme(); if (proto == null && scheme.getSelectionIndex() >= 0) proto = scheme.getItem(scheme.getSelectionIndex()); if (uri.getPath() == null) { selectionIncomplete( NLS.bind( UIText.RepositorySelectionPage_fieldRequired, unamp(UIText.RepositorySelectionPage_promptPath), proto)); return; } if (Protocol.FILE.handles(finalURI)) { String badField = null; if (uri.getHost() != null) badField = UIText.RepositorySelectionPage_promptHost; else if (uri.getUser() != null) badField = UIText.RepositorySelectionPage_promptUser; else if (uri.getPass() != null) badField = UIText.RepositorySelectionPage_promptPassword; if (badField != null) { selectionIncomplete( NLS.bind(UIText.RepositorySelectionPage_fieldNotSupported, unamp(badField), proto)); return; } final File d = FS.DETECTED.resolve(new File("."), uri.getPath()); // $NON-NLS-1$ if (!d.exists()) { selectionIncomplete( NLS.bind(UIText.RepositorySelectionPage_fileNotFound, d.getAbsolutePath())); return; } selectionComplete(finalURI, null); return; } if (uri.getHost() == null) { selectionIncomplete( NLS.bind( UIText.RepositorySelectionPage_fieldRequired, unamp(UIText.RepositorySelectionPage_promptHost), proto)); return; } if (Protocol.GIT.handles(finalURI)) { String badField = null; if (uri.getUser() != null) badField = UIText.RepositorySelectionPage_promptUser; else if (uri.getPass() != null) badField = UIText.RepositorySelectionPage_promptPassword; if (badField != null) { selectionIncomplete( NLS.bind(UIText.RepositorySelectionPage_fieldNotSupported, unamp(badField), proto)); return; } } if (Protocol.HTTP.handles(finalURI) || Protocol.HTTPS.handles(finalURI)) { UserPasswordCredentials credentials = getSecureStoreCredentials(finalURI); if (credentials != null) { String u = credentials.getUser(); String p = credentials.getPassword(); String uriUser = finalURI.getUser(); if (uriUser == null) { if (setSafeUser(u) || setSafePassword(p)) setStoreInSecureStore(true); } else if (uriUser.length() != 0 && uriUser.equals(u)) { if (setSafePassword(p)) setStoreInSecureStore(true); } } } selectionComplete(finalURI, null); return; } catch (URISyntaxException e) { selectionIncomplete(e.getReason()); return; } catch (Exception e) { Activator.logError( NLS.bind(UIText.RepositorySelectionPage_errorValidating, getClass().getName()), e); selectionIncomplete(UIText.RepositorySelectionPage_internalError); return; } } else { assert remoteButton.getSelection(); selectionComplete(null, remoteConfig); return; } }