1 14 15 package org.eclipse.team.internal.ccvs.ui; 16 17 import java.lang.reflect.InvocationTargetException ; 18 import java.net.URL ; 19 import java.util.*; 20 21 import org.eclipse.core.resources.IResource; 22 import org.eclipse.core.resources.IResourceStatus; 23 import org.eclipse.core.runtime.*; 24 import org.eclipse.jface.dialogs.*; 25 import org.eclipse.jface.operation.IRunnableWithProgress; 26 import org.eclipse.jface.preference.IPreferenceStore; 27 import org.eclipse.jface.preference.PreferenceConverter; 28 import org.eclipse.jface.resource.ImageDescriptor; 29 import org.eclipse.jface.util.IPropertyChangeListener; 30 import org.eclipse.jface.util.PropertyChangeEvent; 31 import org.eclipse.osgi.util.NLS; 32 import org.eclipse.swt.graphics.RGB; 33 import org.eclipse.swt.widgets.Display; 34 import org.eclipse.swt.widgets.Shell; 35 import org.eclipse.team.core.TeamException; 36 import org.eclipse.team.core.history.IFileRevision; 37 import org.eclipse.team.internal.ccvs.core.*; 38 import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; 39 import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; 40 import org.eclipse.team.internal.ccvs.ui.console.CVSOutputConsole; 41 import org.eclipse.team.internal.ccvs.ui.model.CVSAdapterFactory; 42 import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; 43 import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot; 44 import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager; 45 import org.eclipse.team.internal.ui.*; 46 import org.eclipse.ui.*; 47 import org.eclipse.ui.plugin.AbstractUIPlugin; 48 import org.osgi.framework.BundleContext; 49 50 53 public class CVSUIPlugin extends AbstractUIPlugin { 54 57 public static final String ID = "org.eclipse.team.cvs.ui"; public static final String DECORATOR_ID = "org.eclipse.team.cvs.ui.decorator"; 60 63 public static final String P_DECORATORS_CHANGED = CVSUIPlugin.ID + ".P_DECORATORS_CHANGED"; 65 private Hashtable imageDescriptors = new Hashtable(20); 66 private static List propertyChangeListeners = new ArrayList(5); 67 68 71 private static CVSUIPlugin plugin; 72 73 76 private CVSOutputConsole console; 77 78 81 private RepositoryManager repositoryManager; 82 83 88 public CVSUIPlugin() { 89 super(); 90 plugin = this; 91 } 92 93 98 public static Display getStandardDisplay() { 99 Display display= Display.getCurrent(); 100 if (display == null) { 101 display= Display.getDefault(); 102 } 103 return display; 104 } 105 106 109 protected void createImageDescriptor(String id) { 110 URL url = FileLocator.find(CVSUIPlugin.getPlugin().getBundle(), new Path(ICVSUIConstants.ICON_PATH + id), null); 111 ImageDescriptor desc = ImageDescriptor.createFromURL(url); 112 imageDescriptors.put(id, desc); 113 } 114 115 123 public static IWorkbenchPage getActivePage() { 124 return TeamUIPlugin.getActivePage(); 125 } 126 127 130 public static void addPropertyChangeListener(IPropertyChangeListener listener) { 131 propertyChangeListeners.add(listener); 132 } 133 134 137 public static void removePropertyChangeListener(IPropertyChangeListener listener) { 138 propertyChangeListeners.remove(listener); 139 } 140 141 144 public static void broadcastPropertyChange(PropertyChangeEvent event) { 145 for (Iterator it = propertyChangeListeners.iterator(); it.hasNext();) { 146 IPropertyChangeListener listener = (IPropertyChangeListener)it.next(); 147 listener.propertyChange(event); 148 } 149 } 150 151 157 public static void runWithRefresh(Shell parent, IResource[] resources, 158 IRunnableWithProgress runnable, IProgressMonitor monitor) 159 throws InvocationTargetException , InterruptedException { 160 boolean firstTime = true; 161 while(true) { 162 try { 163 runnable.run(monitor); 164 return; 165 } catch (InvocationTargetException e) { 166 if (! firstTime) throw e; 167 IStatus status = null; 168 if (e.getTargetException() instanceof CoreException) { 169 status = ((CoreException)e.getTargetException()).getStatus(); 170 } else if (e.getTargetException() instanceof TeamException) { 171 status = ((TeamException)e.getTargetException()).getStatus(); 172 } else { 173 throw e; 174 } 175 if (status.getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) { 176 if (promptToRefresh(parent, resources, status)) { 177 try { 178 for (int i = 0; i < resources.length; i++) { 179 resources[i].refreshLocal(IResource.DEPTH_INFINITE, null); 180 } 181 } catch (CoreException coreEx) { 182 log(coreEx); 184 throw e; 185 } 186 firstTime = false; 187 } else { 189 throw new InterruptedException (); 191 } 192 } else { 193 throw e; 194 } 195 } 196 } 197 } 198 199 private static boolean promptToRefresh(final Shell shell, final IResource[] resources, final IStatus status) { 200 final boolean[] result = new boolean[] { false}; 201 Runnable runnable = new Runnable () { 202 public void run() { 203 Shell shellToUse = shell; 204 if (shell == null) { 205 shellToUse = new Shell(Display.getCurrent()); 206 } 207 String question; 208 if (resources.length == 1) { 209 question = NLS.bind(CVSUIMessages.CVSUIPlugin_refreshQuestion, new String [] { status.getMessage(), resources[0].getFullPath().toString() }); 210 } else { 211 question = NLS.bind(CVSUIMessages.CVSUIPlugin_refreshMultipleQuestion, new String [] { status.getMessage() }); 212 } 213 result[0] = MessageDialog.openQuestion(shellToUse, CVSUIMessages.CVSUIPlugin_refreshTitle, question); 214 } 215 }; 216 Display.getDefault().syncExec(runnable); 217 return result[0]; 218 } 219 220 231 public static void runWithProgress(Shell parent, boolean cancelable, 232 final IRunnableWithProgress runnable) throws InvocationTargetException , InterruptedException { 233 Utils.runWithProgress(parent, cancelable, runnable); 234 } 235 236 240 public ImageDescriptor getImageDescriptor(String id) { 241 return (ImageDescriptor)imageDescriptors.get(id); 242 } 243 244 249 public static CVSUIPlugin getPlugin() { 250 return plugin; 251 } 252 253 258 public synchronized RepositoryManager getRepositoryManager() { 259 if (repositoryManager == null) { 260 repositoryManager = new RepositoryManager(); 261 repositoryManager.startup(); 262 } 263 return repositoryManager; 264 } 265 266 269 private void initializeImages() { 270 createImageDescriptor(ICVSUIConstants.IMG_REPOSITORY); 272 createImageDescriptor(ICVSUIConstants.IMG_REFRESH); 273 createImageDescriptor(ICVSUIConstants.IMG_REFRESH_ENABLED); 274 createImageDescriptor(ICVSUIConstants.IMG_REFRESH_DISABLED); 275 createImageDescriptor(ICVSUIConstants.IMG_LINK_WITH_EDITOR); 276 createImageDescriptor(ICVSUIConstants.IMG_LINK_WITH_EDITOR_ENABLED); 277 createImageDescriptor(ICVSUIConstants.IMG_COLLAPSE_ALL); 278 createImageDescriptor(ICVSUIConstants.IMG_COLLAPSE_ALL_ENABLED); 279 createImageDescriptor(ICVSUIConstants.IMG_NEWLOCATION); 280 createImageDescriptor(ICVSUIConstants.IMG_CVSLOGO); 281 createImageDescriptor(ICVSUIConstants.IMG_TAG); 282 createImageDescriptor(ICVSUIConstants.IMG_MODULE); 283 createImageDescriptor(ICVSUIConstants.IMG_CLEAR); 284 createImageDescriptor(ICVSUIConstants.IMG_CLEAR_ENABLED); 285 createImageDescriptor(ICVSUIConstants.IMG_CLEAR_DISABLED); 286 createImageDescriptor(ICVSUIConstants.IMG_BRANCHES_CATEGORY); 287 createImageDescriptor(ICVSUIConstants.IMG_VERSIONS_CATEGORY); 288 createImageDescriptor(ICVSUIConstants.IMG_DATES_CATEGORY); 289 createImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION); 290 createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_MERGE); 291 createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_SHARE); 292 createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_DIFF); 293 createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_KEYWORD); 294 createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION); 295 createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_IMPORT); 296 createImageDescriptor(ICVSUIConstants.IMG_MERGEABLE_CONFLICT); 297 createImageDescriptor(ICVSUIConstants.IMG_QUESTIONABLE); 298 createImageDescriptor(ICVSUIConstants.IMG_MERGED); 299 createImageDescriptor(ICVSUIConstants.IMG_EDITED); 300 createImageDescriptor(ICVSUIConstants.IMG_NO_REMOTEDIR); 301 createImageDescriptor(ICVSUIConstants.IMG_CVS_CONSOLE); 302 createImageDescriptor(ICVSUIConstants.IMG_DATE); 303 createImageDescriptor(ICVSUIConstants.IMG_CHANGELOG); 304 createImageDescriptor(ICVSUIConstants.IMG_FILTER_HISTORY); 305 createImageDescriptor(ICVSUIConstants.IMG_LOCALMODE); 306 createImageDescriptor(ICVSUIConstants.IMG_LOCALREMOTE_MODE); 307 createImageDescriptor(ICVSUIConstants.IMG_REMOTEMODE); 308 createImageDescriptor(ICVSUIConstants.IMG_LOCALMODE_DISABLED); 309 createImageDescriptor(ICVSUIConstants.IMG_LOCALREMOTE_MODE_DISABLED); 310 createImageDescriptor(ICVSUIConstants.IMG_REMOTEMODE_DISABLED); 311 createImageDescriptor(ICVSUIConstants.IMG_LOCALREVISION_TABLE); 312 createImageDescriptor(ICVSUIConstants.IMG_REMOTEREVISION_TABLE); 313 createImageDescriptor(ICVSUIConstants.IMG_COMPARE_VIEW); 314 315 createImageDescriptor("glyphs/glyph1.gif"); createImageDescriptor("glyphs/glyph2.gif"); createImageDescriptor("glyphs/glyph3.gif"); createImageDescriptor("glyphs/glyph4.gif"); createImageDescriptor("glyphs/glyph5.gif"); createImageDescriptor("glyphs/glyph6.gif"); createImageDescriptor("glyphs/glyph7.gif"); createImageDescriptor("glyphs/glyph8.gif"); } 325 330 public static void log(IStatus status) { 331 getPlugin().getLog().log(status); 332 } 333 334 public static void log(CoreException e) { 335 log(e.getStatus().getSeverity(), CVSUIMessages.simpleInternal, e); 336 } 337 338 341 public static void log(int severity, String message, Throwable e) { 342 log(new Status(severity, ID, 0, message, e)); 343 } 344 345 public static final int PERFORM_SYNC_EXEC = 1; 347 public static final int LOG_TEAM_EXCEPTIONS = 2; 348 public static final int LOG_CORE_EXCEPTIONS = 4; 349 public static final int LOG_OTHER_EXCEPTIONS = 8; 350 public static final int LOG_NONTEAM_EXCEPTIONS = LOG_CORE_EXCEPTIONS | LOG_OTHER_EXCEPTIONS; 351 352 359 public static IStatus openError(Shell shell, String title, String message, Throwable exception) { 360 return openError(shell, title, message, exception, LOG_OTHER_EXCEPTIONS); 361 } 362 363 371 public static IStatus openError(Shell providedShell, String title, String message, Throwable exception, int flags) { 372 if (exception instanceof InvocationTargetException ) { 374 Throwable target = ((InvocationTargetException )exception).getTargetException(); 375 if (target instanceof RuntimeException ) { 377 throw (RuntimeException )target; 378 } 379 if (target instanceof Error ) { 380 throw (Error )target; 381 } 382 return openError(providedShell, title, message, target, flags); 383 } 384 385 IStatus status = null; 387 boolean log = false; 388 if (exception instanceof CoreException) { 389 status = ((CoreException)exception).getStatus(); 390 log = ((flags & LOG_CORE_EXCEPTIONS) > 0); 391 } else if (exception instanceof TeamException) { 392 status = ((TeamException)exception).getStatus(); 393 log = ((flags & LOG_TEAM_EXCEPTIONS) > 0); 394 } else if (exception instanceof InterruptedException ) { 395 return new CVSStatus(IStatus.OK, CVSUIMessages.ok); 396 } else if (exception != null) { 397 status = new CVSStatus(IStatus.ERROR, CVSUIMessages.internal, exception); 398 log = ((flags & LOG_OTHER_EXCEPTIONS) > 0); 399 if (title == null) title = CVSUIMessages.internal; 400 } 401 402 if (status.getCode() == IResourceStatus.BUILD_FAILED) { 404 message = CVSUIMessages.buildError; 405 log = true; 406 } 407 408 if (status.isMultiStatus() && status.getChildren().length == 1) { 410 status = status.getChildren()[0]; 411 } 412 if (status.isOK()) return status; 413 414 if (log) CVSUIPlugin.log(status.getSeverity(), status.getMessage(), exception); 416 417 final String displayTitle = title; 419 final String displayMessage = message; 420 final IStatus displayStatus = status; 421 final IOpenableInShell openable = new IOpenableInShell() { 422 public void open(Shell shell) { 423 if (displayStatus.getSeverity() == IStatus.INFO && !displayStatus.isMultiStatus()) { 424 MessageDialog.openInformation(shell, CVSUIMessages.information, displayStatus.getMessage()); 425 } else { 426 ErrorDialog.openError(shell, displayTitle, displayMessage, displayStatus); 427 } 428 } 429 }; 430 openDialog(providedShell, openable, flags); 431 432 return status; 434 } 435 436 440 public interface IOpenableInShell { 441 public void open(Shell shell); 442 } 443 444 453 public static void openDialog(Shell providedShell, final IOpenableInShell openable, int flags) { 454 if (providedShell == null) { 456 IWorkbenchWindow window = CVSUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow(); 457 if (window != null) { 458 providedShell = window.getShell(); 459 flags = flags | PERFORM_SYNC_EXEC; 461 } 462 } 463 464 final Shell shell = providedShell; 466 Runnable outerRunnable = new Runnable () { 467 public void run() { 468 Shell displayShell; 469 if (shell == null) { 470 Display display = Display.getCurrent(); 471 displayShell = new Shell(display); 472 } else { 473 displayShell = shell; 474 } 475 openable.open(displayShell); 476 if (shell == null) { 477 displayShell.dispose(); 478 } 479 } 480 }; 481 482 if (shell == null || (flags & PERFORM_SYNC_EXEC) > 0) { 484 Display display; 485 if (shell == null) { 486 display = Display.getCurrent(); 487 if (display == null) { 488 display = Display.getDefault(); 489 } 490 } else { 491 display = shell.getDisplay(); 492 } 493 display.syncExec(outerRunnable); 494 } else { 495 outerRunnable.run(); 496 } 497 } 498 499 500 503 protected void initializeDefaultPluginPreferences() { 504 IPreferenceStore store = getPreferenceStore(); 505 Preferences corePrefs = CVSProviderPlugin.getPlugin().getPluginPreferences(); 507 508 store.setDefault(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY, false); 509 store.setDefault(ICVSUIConstants.PREF_SHOW_COMMENTS, true); 510 store.setDefault(ICVSUIConstants.PREF_WRAP_COMMENTS, true); 511 store.setDefault(ICVSUIConstants.PREF_SHOW_TAGS, true); 512 store.setDefault(ICVSUIConstants.PREF_SHOW_SEARCH, false); 513 store.setDefault(ICVSUIConstants.PREF_REVISION_MODE, 0); 514 store.setDefault(ICVSUIConstants.PREF_GROUPBYDATE_MODE, true); 515 store.setDefault(ICVSUIConstants.PREF_HISTORY_VIEW_EDITOR_LINKING, false); 516 store.setDefault(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES, CVSProviderPlugin.DEFAULT_PRUNE); 517 store.setDefault(ICVSUIConstants.PREF_TIMEOUT, CVSProviderPlugin.DEFAULT_TIMEOUT); 518 store.setDefault(ICVSUIConstants.PREF_CONSIDER_CONTENTS, true); 519 store.setDefault(ICVSUIConstants.PREF_COMPRESSION_LEVEL, CVSProviderPlugin.DEFAULT_COMPRESSION_LEVEL); 520 store.setDefault(ICVSUIConstants.PREF_TEXT_KSUBST, CVSProviderPlugin.DEFAULT_TEXT_KSUBST_OPTION.toMode()); 521 store.setDefault(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND, true); 522 store.setDefault(ICVSUIConstants.PREF_REPLACE_UNMANAGED, true); 523 store.setDefault(ICVSUIConstants.PREF_CVS_RSH, CVSProviderPlugin.DEFAULT_CVS_RSH); 524 store.setDefault(ICVSUIConstants.PREF_CVS_RSH_PARAMETERS, CVSProviderPlugin.DEFAULT_CVS_RSH_PARAMETERS); 525 store.setDefault(ICVSUIConstants.PREF_CVS_SERVER, CVSProviderPlugin.DEFAULT_CVS_SERVER); 526 store.setDefault(ICVSUIConstants.PREF_EXT_CONNECTION_METHOD_PROXY, "ext"); store.setDefault(ICVSUIConstants.PREF_PROMPT_ON_CHANGE_GRANULARITY, true); 528 store.setDefault(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION, true); 529 store.setDefault(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG, CVSProviderPlugin.DEFAULT_CONFIRM_MOVE_TAG); 530 store.setDefault(ICVSUIConstants.PREF_DEBUG_PROTOCOL, false); 531 store.setDefault(ICVSUIConstants.PREF_WARN_REMEMBERING_MERGES, true); 532 store.setDefault(ICVSUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG, false); 533 store.setDefault(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT, false); 534 store.setDefault(ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, false); 535 store.setDefault(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, true); 536 store.setDefault(ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT, false); 537 store.setDefault(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, false); 538 store.setDefault(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, 1000); 539 store.setDefault(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY, RepositoryManager.DEFAULT_MAX_COMMENTS); 540 541 PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, new RGB(0, 0, 0)); 542 PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_MESSAGE_COLOR, new RGB(0, 0, 255)); 543 PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_ERROR_COLOR, new RGB(255, 0, 0)); 544 store.setDefault(ICVSUIConstants.PREF_CONSOLE_SHOW_ON_MESSAGE, false); 545 store.setDefault(ICVSUIConstants.PREF_CONSOLE_LIMIT_OUTPUT, true); 546 store.setDefault(ICVSUIConstants.PREF_CONSOLE_HIGH_WATER_MARK, 500000); 547 store.setDefault(ICVSUIConstants.PREF_CONSOLE_WRAP, false); 548 store.setDefault(ICVSUIConstants.PREF_CONSOLE_WIDTH, 80); 549 550 store.setDefault(ICVSUIConstants.PREF_FILETEXT_DECORATION, CVSDecoratorConfiguration.DEFAULT_FILETEXTFORMAT); 551 store.setDefault(ICVSUIConstants.PREF_FOLDERTEXT_DECORATION, CVSDecoratorConfiguration.DEFAULT_FOLDERTEXTFORMAT); 552 store.setDefault(ICVSUIConstants.PREF_PROJECTTEXT_DECORATION, CVSDecoratorConfiguration.DEFAULT_PROJECTTEXTFORMAT); 553 554 store.setDefault(ICVSUIConstants.PREF_FIRST_STARTUP, true); 555 store.setDefault(ICVSUIConstants.PREF_ADDED_FLAG, CVSDecoratorConfiguration.DEFAULT_ADDED_FLAG); 556 store.setDefault(ICVSUIConstants.PREF_DIRTY_FLAG, CVSDecoratorConfiguration.DEFAULT_DIRTY_FLAG); 557 store.setDefault(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, true); 558 store.setDefault(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION, true); 559 store.setDefault(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, false); 560 store.setDefault(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION, true); 561 store.setDefault(ICVSUIConstants.PREF_CALCULATE_DIRTY, true); 562 store.setDefault(ICVSUIConstants.PREF_USE_FONT_DECORATORS, false); 563 store.setDefault(ICVSUIConstants.PREF_PROMPT_ON_MIXED_TAGS, true); 564 store.setDefault(ICVSUIConstants.PREF_PROMPT_ON_SAVING_IN_SYNC, true); 565 store.setDefault(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS, ICVSUIConstants.OPTION_PROMPT); 566 567 store.setDefault(ICVSUIConstants.PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS, CVSPerspective.ID); 568 store.setDefault(ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS, MessageDialogWithToggle.PROMPT); 569 store.setDefault(ICVSUIConstants.PREF_USE_QUICKDIFFANNOTATE, MessageDialogWithToggle.ALWAYS); 570 store.setDefault(ICVSUIConstants.PREF_ANNOTATE_PROMPTFORBINARY, MessageDialogWithToggle.PROMPT); 571 store.setDefault(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS, MessageDialogWithToggle.PROMPT); 572 store.setDefault(ICVSUIConstants.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT, MessageDialogWithToggle.NEVER); 573 store.setDefault(ICVSUIConstants.PREF_ALLOW_COMMIT_WITH_WARNINGS, MessageDialogWithToggle.ALWAYS); 574 store.setDefault(ICVSUIConstants.PREF_ALLOW_COMMIT_WITH_ERRORS, MessageDialogWithToggle.PROMPT); 575 576 store.setDefault(ICVSUIConstants.PREF_UPDATE_HANDLING, ICVSUIConstants.PREF_UPDATE_HANDLING_TRADITIONAL); 577 store.setDefault(ICVSUIConstants.PREF_UPDATE_PREVIEW, ICVSUIConstants.PREF_UPDATE_PREVIEW_IN_SYNCVIEW); 578 579 store.setDefault(ICVSUIConstants.PREF_ENABLE_MODEL_SYNC, true); 580 store.setDefault(ICVSUIConstants.PREF_OPEN_COMPARE_EDITOR_FOR_SINGLE_FILE, true); 581 582 store.setDefault(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getDefaultBoolean(CVSProviderPlugin.READ_ONLY)); 584 store.setDefault(ICVSUIConstants.PREF_EDIT_ACTION, ICVSUIConstants.PREF_EDIT_IN_BACKGROUND); 585 store.setDefault(ICVSUIConstants.PREF_EDIT_PROMPT, ICVSUIConstants.PREF_EDIT_PROMPT_IF_EDITORS); 586 store.setDefault(ICVSUIConstants.PREF_UPDATE_PROMPT, ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER); 587 store.setValue(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getBoolean(CVSProviderPlugin.READ_ONLY)); 589 590 CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(store.getBoolean(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES)); 592 CVSProviderPlugin.getPlugin().setTimeout(store.getInt(ICVSUIConstants.PREF_TIMEOUT)); 593 CVSProviderPlugin.getPlugin().setCvsRshCommand(store.getString(ICVSUIConstants.PREF_CVS_RSH)); 594 CVSProviderPlugin.getPlugin().setCvsRshParameters(store.getString(ICVSUIConstants.PREF_CVS_RSH_PARAMETERS)); 595 CVSProviderPlugin.getPlugin().setCvsServer(store.getString(ICVSUIConstants.PREF_CVS_SERVER)); 596 CVSRepositoryLocation.setExtConnectionMethodProxy(store.getString(ICVSUIConstants.PREF_EXT_CONNECTION_METHOD_PROXY)); 597 CVSProviderPlugin.getPlugin().setQuietness(CVSPreferencesPage.getQuietnessOptionFor(store.getInt(ICVSUIConstants.PREF_QUIETNESS))); 598 CVSProviderPlugin.getPlugin().setCompressionLevel(store.getInt(ICVSUIConstants.PREF_COMPRESSION_LEVEL)); 599 CVSProviderPlugin.getPlugin().setReplaceUnmanaged(store.getBoolean(ICVSUIConstants.PREF_REPLACE_UNMANAGED)); 600 CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(KSubstOption.fromMode(store.getString(ICVSUIConstants.PREF_TEXT_KSUBST))); 601 CVSProviderPlugin.getPlugin().setUsePlatformLineend(store.getBoolean(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND)); 602 CVSProviderPlugin.getPlugin().setRepositoriesAreBinary(store.getBoolean(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY)); 603 CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION)); 604 CVSProviderPlugin.getPlugin().setDebugProtocol(CVSProviderPlugin.getPlugin().isDebugProtocol() || store.getBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL)); 605 CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT)); 606 607 if (store.getBoolean(ICVSUIConstants.PREF_SHOW_AUTHOR_IN_EDITOR)) { 609 store.setValue(ICVSUIConstants.PREF_SHOW_AUTHOR_IN_EDITOR, false); 610 IPreferenceStore teamStore = TeamUIPlugin.getPlugin().getPreferenceStore(); 611 if (teamStore.isDefault(IPreferenceIds.SHOW_AUTHOR_IN_COMPARE_EDITOR)) 612 teamStore.setValue(IPreferenceIds.SHOW_AUTHOR_IN_COMPARE_EDITOR, true); 613 } 614 } 615 616 619 public void start(BundleContext context) throws Exception { 620 super.start(context); 621 622 initializeImages(); 623 624 CVSAdapterFactory factory = new CVSAdapterFactory(); 625 Platform.getAdapterManager().registerAdapters(factory, ICVSRemoteFile.class); 626 Platform.getAdapterManager().registerAdapters(factory, ICVSRemoteFolder.class); 627 Platform.getAdapterManager().registerAdapters(factory, ICVSRepositoryLocation.class); 628 Platform.getAdapterManager().registerAdapters(factory, RepositoryRoot.class); 629 630 try { 631 console = new CVSOutputConsole(); 632 } catch (RuntimeException e) { 633 log(IStatus.ERROR, "Errors occurred starting the CVS console", e); } 636 637 IPreferenceStore store = getPreferenceStore(); 638 if (store.getBoolean(ICVSUIConstants.PREF_FIRST_STARTUP)) { 639 PlatformUI.getWorkbench().getDecoratorManager().setEnabled(CVSLightweightDecorator.ID, true); 646 store.setValue(ICVSUIConstants.PREF_FIRST_STARTUP, false); 647 } 648 649 } 650 651 654 public void stop(BundleContext context) throws Exception { 655 try { 656 try { 657 if (repositoryManager != null) 658 repositoryManager.shutdown(); 659 } catch (TeamException e) { 660 throw new CoreException(e.getStatus()); 661 } 662 663 if (console != null) 664 console.shutdown(); 665 } finally { 666 super.stop(context); 667 } 668 } 669 670 673 public CVSOutputConsole getConsole() { 674 return console; 675 } 676 677 public IEditorPart openEditor(ICVSRemoteFile file, IProgressMonitor monitor) throws InvocationTargetException { 678 IWorkbench workbench = getWorkbench(); 679 IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage(); 680 try { 681 return Utils.openEditor(page, (IFileRevision)file.getAdapter(IFileRevision.class), monitor); 682 } catch (CoreException e) { 683 throw new InvocationTargetException (e); 684 } 685 } 686 687 692 public boolean isUseProjectNameOnCheckout() { 693 return getPreferenceStore().getBoolean(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT); 694 } 695 696 public ActiveChangeSetManager getChangeSetManager() { 697 return CVSProviderPlugin.getPlugin().getChangeSetManager(); 698 } 699 } 700 | Popular Tags |