better feedback importing bookmarks, show where they end up in manager on

completion (bug 242545)
This commit is contained in:
pinkerton%aol.net 2004-06-01 22:21:33 +00:00
Родитель b99c20fb40
Коммит 656d92855a
9 изменённых файлов: 65 добавлений и 28 удалений

Просмотреть файл

@ -3,18 +3,18 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>40 422 356 240 0 0 1152 848 </string>
<string>830 29 356 240 0 0 1280 1002 </string>
<key>IBFramework Version</key>
<string>349.0</string>
<string>364.0</string>
<key>IBLockedObjects</key>
<array>
<integer>5</integer>
<integer>26</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>5</integer>
<integer>26</integer>
</array>
<key>IBSystem Version</key>
<string>7B85</string>
<string>7F44</string>
</dict>
</plist>

Двоичные данные
camino/resources/localized/English.lproj/BookmarkImportDlg.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -51,6 +51,6 @@
-(IBAction) import:(id)aSender;
-(IBAction) loadOpenPanel:(id)aSender;
-(IBAction) nullAction:(id)aSender;
-(void) alertSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
@end

Просмотреть файл

@ -40,11 +40,15 @@
#import "BookmarkImportDlgController.h"
#import "BookmarkManager.h"
#import "BookmarkFolder.h"
#import "MainController.h"
#import "BrowserWindowController.h"
#import "BookmarkViewController.h"
@interface BookmarkImportDlgController (Private)
-(void) tryAddImportFromBrowser: (NSString *) aBrowserName withBookmarkPath: (NSString *) aPath;
-(NSString *) getSaltedBookmarkPathForProfile: (NSString *) aPath;
-(void) beginImportFrom:(NSString *) aPath intoFolder:(BookmarkFolder *) aFolder;
@end
@ -53,6 +57,7 @@
-(void) windowDidLoad
{
[self buildAvailableFileList];
[[self window] center];
}
// Check for common webbrower bookmark files and, if they exist, add import buttons.
@ -60,7 +65,7 @@
{
NSString *mozPath;
// Remove everything but the "Select a File..." option, on the off-chance that someone brings
// Remove everything but the "Select a file..." option, on the off-chance that someone brings
// up the import dialog, throws away a profile, then brings up the import dialog again
while ([mBrowserListButton numberOfItems] > 1)
[mBrowserListButton removeItemAtIndex:0];
@ -125,16 +130,12 @@
-(IBAction) cancel:(id)aSender
{
[NSApp stopModal];
[NSApp endSheet:[self window]];
[[self window] orderOut:self];
}
-(IBAction) import:(id)aSender
{
[NSApp stopModal];
[NSApp endSheet:[self window]];
[[self window] orderOut:self];
NSMenuItem *selectedItem = [mBrowserListButton selectedItem];
BookmarkFolder *importFolder = [[[BookmarkManager sharedBookmarkManager] rootBookmarks] addBookmarkFolder];
NSString *titleString;
@ -144,29 +145,62 @@
titleString = [[NSString alloc] initWithFormat:NSLocalizedString(@"Imported %@ Bookmarks",@"Imported %@ Bookmarks"),[selectedItem title]];
[importFolder setTitle:titleString];
[titleString release];
[[BookmarkManager sharedBookmarkManager] importBookmarks:[selectedItem representedObject] intoFolder:importFolder];
[self beginImportFrom:[selectedItem representedObject] intoFolder:importFolder];
}
-(IBAction) loadOpenPanel:(id)aSender
{
[NSApp stopModal];
[NSApp endSheet:[self window]];
[[self window] orderOut:self];
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
[openPanel setCanChooseFiles: YES];
[openPanel setCanChooseDirectories: NO];
[openPanel setAllowsMultipleSelection: NO];
[openPanel setPrompt: @"Import"];
NSArray* array = [NSArray arrayWithObjects: @"htm",@"html",@"xml", @"plist",nil];
int result = [openPanel runModalForDirectory: nil
file: nil
types: array];
if (result == NSOKButton) {
NSString *pathToFile = [[openPanel filenames] objectAtIndex:0];
BookmarkManager *bm = [BookmarkManager sharedBookmarkManager];
BookmarkFolder *importFolder = [[bm rootBookmarks] addBookmarkFolder];
BookmarkFolder *importFolder = [[[BookmarkManager sharedBookmarkManager] rootBookmarks] addBookmarkFolder];
[importFolder setTitle:NSLocalizedString(@"Imported Bookmarks",@"Imported Bookmarks")];
[bm importBookmarks:pathToFile intoFolder:importFolder];
[self beginImportFrom:pathToFile intoFolder:importFolder];
}
}
-(void) beginImportFrom:(NSString *) aPath intoFolder:(BookmarkFolder *) aFolder
{
[mCancelButton setEnabled:NO];
[mImportButton setEnabled:NO];
BOOL success = [[BookmarkManager sharedBookmarkManager] importBookmarks:aPath intoFolder:aFolder];
[mCancelButton setEnabled:YES];
[mImportButton setEnabled:YES];
if (success) { //show them the imported bookmarks if import succeeded
[[self window] orderOut:self];
BrowserWindowController *windowController = [(MainController *)[NSApp delegate] openBrowserWindowWithURL:@"" andReferrer:nil behind:nil];
[windowController manageBookmarks:self];
BookmarkViewController *bmController = [windowController bookmarkViewController];
[bmController selectContainer:[bmController containerCount]-1];
} else {
NSBeginAlertSheet(NSLocalizedString(@"ImportFailureTitle", @"Import Failed"), // title
@"", // default button
nil, // no cancel buttton
nil, // no third button
[self window], // window
self, // delegate
@selector(alertSheetDidEnd:returnCode:contextInfo:),
nil, // no dismiss sel
(void *)NULL, // no context
[NSString stringWithFormat:NSLocalizedString(@"ImportFailureMessage", @"The file '%@' is not a supported bookmark file type."), [aPath lastPathComponent]]
);
}
}
-(void) alertSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
[[self window] orderOut:self];
}
@end

Просмотреть файл

@ -98,7 +98,7 @@
// Reading bookmark files
-(BOOL) readBookmarks;
-(void) startImportBookmarks;
-(void) importBookmarks:(NSString *)pathToFile intoFolder:(BookmarkFolder *)aFolder;
-(BOOL) importBookmarks:(NSString *)pathToFile intoFolder:(BookmarkFolder *)aFolder;
-(NSString *)decodedHTMLfile:(NSString *)pathToFile;
-(BOOL)readHTMLFile:(NSString *)pathToFile intoFolder:(BookmarkFolder *)aFolder;
-(BOOL)readCaminoXMLFile:(NSString *)pathToFile intoFolder:(BookmarkFolder *)aFolder;

Просмотреть файл

@ -616,18 +616,14 @@ static unsigned gFirstUserCollection = 0;
if (!mImportDlgController)
mImportDlgController = [[BookmarkImportDlgController alloc] initWithWindowNibName:@"BookmarkImportDlg"];
[mImportDlgController buildAvailableFileList];
[NSApp beginSheet:[mImportDlgController window]
modalForWindow:[[NSApp delegate] getFrontmostBrowserWindow]
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
[mImportDlgController showWindow:nil];
}
-(void) importBookmarks:(NSString *)pathToFile intoFolder:(BookmarkFolder *)aFolder
-(BOOL) importBookmarks:(NSString *)pathToFile intoFolder:(BookmarkFolder *)aFolder
{
//I feel dirty doing it this way. But we'll check file extension
//to figure out how to handle this. Damn you, Steve Jobs!!
NSUndoManager *undoManager =[self undoManager];
NSUndoManager *undoManager = [self undoManager];
[undoManager beginUndoGrouping];
BOOL success = NO;
NSString *extension =[pathToFile pathExtension];
@ -642,11 +638,12 @@ static unsigned gFirstUserCollection = 0;
if (!success) {
success = [self readHTMLFile:pathToFile intoFolder:aFolder];
if (!success)
[self readCaminoXMLFile:pathToFile intoFolder:aFolder];
success = [self readCaminoXMLFile:pathToFile intoFolder:aFolder];
}
[[undoManager prepareWithInvocationTarget:[self rootBookmarks]] deleteChild:aFolder];
[undoManager endUndoGrouping];
[undoManager setActionName:NSLocalizedString(@"Import Bookmarks",@"Import Bookmarks")];
return success;
}
// spits out html file as NSString with proper encoding. it's pretty shitty, frankly.

Просмотреть файл

@ -96,6 +96,7 @@
-(IBAction) locateBookmark:(id)aSender;
-(int) containerCount;
-(void) selectContainer:(int)inRowIndex;
-(void) selectLastContainer;
-(NSMutableDictionary *)expandedStatusDictionary;

Просмотреть файл

@ -791,6 +791,11 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
//
// table view things
//
- (int) containerCount
{
return [mRootBookmarks count];
}
- (void) selectContainer:(int)inRowIndex
{
[mContainerPane selectRow:inRowIndex byExtendingSelection:NO];