Bundle-PBib
view release on metacpan or search on metacpan
lib/PBibTk/Main.pm view on Meta::CPAN
-l => ['%0',0],
-r => ['%100',0],
-b => ['%100',0]);
my $bf3 = $b3->Frame()->pack();
#myline hoch ---------------------------------------------------
# menu inside a menu frame
my $mf = $win->Menu(-type => 'menubar');
$win->configure(-menu => $mf);
$self->initMenu($mf, $win);
}
sub initMenu {
my ($self, $mf, $win) = @_;
$self->initFileMenu($mf, $win);
$self->initBiblioMenu($mf, $win);
$self->initPaperMenu($mf, $win);
}
sub initFileMenu {
my ($self, $mf, $win, $model) = @_;
my $cmd;
$model = $self unless defined $model;
my $mb = $mf->cascade(-label => '~File'); ###, -tearoff => 0);
$cmd = [ $model, 'browsePaperFile' ];
$mb->command(-label => "~Open New Paper", -command => $cmd,
-accelerator => 'Ctrl-O' );
$win->bind('<Control-Key-o>' => $cmd);
$mb->separator();
$cmd = [ $model, 'importBiblioRefs' ];
$mb->command(-label => "~Import References ...", -command => $cmd );
#$win->bind('<Control-w>' => $cmd);
$cmd = [ $model, 'exportBiblioRefs' ];
$mb->command(-label => "~Export References ...", -command => $cmd );
#$win->bind('<Control-w>' => $cmd);
$mb->separator();
$cmd = sub { Tk::exit(0); };
$mb->command(-label => '~Quit', -command => $cmd,
-accelerator => 'Ctrl-Q');
$win->bind('<Control-q>' => $cmd);
}
sub initBiblioMenu {
my ($self, $mf, $win, $model) = @_;
my $cmd;
$model = $self unless defined $model;
my $mb = $mf->cascade(-label => '~Biblio'); ###, -tearoff => 0);
# $cmd = sub { $model->showSelectedBiblioReference(); };
$cmd = [$model, 'showSelectedBiblioReference'];
$mb->command(-label => 'Show ~Reference', -command => $cmd,
-accelerator => 'Ctrl-R' );
$win->bind('<Control-r>' => $cmd);
# $win->bind('<Return>' => $cmd);
$cmd = [ $model, 'clipboardSelectedBiblioReferenceId'];
$mb->command(-label => '~Copy CiteKey to Clipboard', -command => $cmd,
-accelerator => 'Ctrl-C' );
$win->bind('<Control-c>' => $cmd);
$cmd = sub { $model->searchSelectedBiblioReferenceId(); };
$mb->command(-label => '~Search CiteKey in Paper', -command => $cmd,
-accelerator => 'Ctrl-J' );
$win->bind('<Control-j>' => $cmd);
$cmd = sub { $model->refList()->focus(); };
$mb->command(-label => 'Keyboardfocus to ~Biblio', -command => $cmd,
-accelerator => 'Ctrl-B' );
$win->bind('<Control-b>' => $cmd);
$mb->separator();
# $cmd = sub{$model->queryAuthor()}; # start search via menu
# better: set focus to queryAutor input field
$cmd = [ $model, 'entryFocusAndSelectAll',
$self->queryAuthorList() ];
$mb->command(-label => "Query ~Author", -command => $cmd,
-accelerator => 'Ctrl-A' );
$win->bind('<Control-a>' => $cmd);
#$cmd = sub{$model->queryKeyword()};
# instead of start query: set focus to keyword input field
$cmd = [ $model, 'entryFocusAndSelectAll',
$self->queryKeywordList(), ];
$mb->command(-label => "Query ~Keyword", -command => $cmd,
-accelerator => 'Ctrl-F' );
$win->bind('<Control-f>' => $cmd);
$mb->separator();
$cmd = sub{$model->updateBiblioRefs()};
$mb->command(-label => "~Update from database",
-command => $cmd,
-accelerator => 'Ctrl-N' );
$win->bind('<Control-n>' => $cmd);
}
sub initPaperMenu {
my ($self, $mf, $win) = @_;
my $cmd;
my $mb = $mf->cascade(-label => '~Paper');
$cmd = sub { $self->showSelectedPaperReference(); };
$mb->command(-label => 'Show ~Reference', -command => $cmd,
-accelerator => 'Ctrl-T' );
$win->bind('<Control-Key-t>' => $cmd);
$cmd = sub { $self->clipboardSelectedPaperReferenceId(); };
$mb->command(-label => '~Copy CiteKey to Clipboard', -command => $cmd,
-accelerator => 'Ctrl-X' );
$win->bind('<Control-Key-x>' => $cmd);
$cmd = sub { $self->searchSelectedPaperReferenceId(); };
$mb->command(-label => '~Search CiteKey in Paper', -command => $cmd,
-accelerator => 'Ctrl-G' );
$win->bind('<Control-Key-g>' => $cmd);
$cmd = sub { $self->foundList()->focus(); };
$mb->command(-label => 'Keyboardfocus to ~Paper', -command => $cmd,
-accelerator => 'Ctrl-P' );
$win->bind('<Control-p>' => $cmd);
$mb->separator();
$cmd = sub { openFile($filename); };
$mb->command(-label => '~Edit Paper', -command => $cmd,
-accelerator => 'Ctrl-E' );
$win->bind('<Control-Key-e>' => $cmd);
$mb->separator();
$mb->command(-label => "Read & ~Analyze Paper", -command => [ $self, 'readPaperFile' ]);
$cmd = [ $self, 'processPaperFile' ];
$mb->command(-label => "Pr~ocess Paper",
-command => $cmd,
-accelerator => 'Ctrl-S' );
$win->bind('<Control-Key-s>' => $cmd);
$mb->command(-label => "~Write newrefs file", -command => [$self => 'writeNewRefs']);
}
sub refList {
my $self = shift;
# access window first, to ensure it's created.
$self->window();
return $self->{'refList'};
}
sub foundList {
my $self = shift;
# access window first, to ensure it's created.
$self->window();
return $self->{'foundList'};
}
sub queryAuthorList { return shift->{'queryAuthorList'}; }
sub queryKeywordList { return shift->{'queryKeywordList'}; }
sub chosenLabel { my $self = shift; return $self->{'chosenLabel'}; }
sub refListLabel { my $self = shift; return $self->{'refListLabel'}; }
sub foundListLabel { my $self = shift; return $self->{'foundListLabel'}; }
sub refListSelection { my $self = shift; return $self->refList()->curselection(); }
sub foundListSelection { my $self = shift; return $self->foundList()->curselection(); }
sub litRefs { my $self = shift; return $self->{'litRefs'}; }
sub initDropSite {
# I guess this doesn't qork jet under Win32 ...
lib/PBibTk/Main.pm view on Meta::CPAN
'CiteKey', 'Category',
'PBibNote', ##### 'Project', 'Subject', 'BibNote',
]);
$q->show();
}
sub saveQueryHistory {
my ($self) = @_;
open OUT, "> .pbibtk-author-history.txt";
foreach my $a (@queryAuthorHistory) { print OUT "$a\n"; }
close OUT;
open OUT, "> .pbibtk-keyword-history.txt";
foreach my $a (@queryKeywordHistory) { print OUT "$a\n"; }
close OUT;
}
sub loadQueryHistory {
my ($self) = @_;
if( open IN, "< .pbibtk-author-history.txt" ) {
chomp(@queryAuthorHistory = <IN>);
close IN;
}
if( open IN, "< .pbibtk-keyword-history.txt" ) {
chomp(@queryKeywordHistory = <IN>);
close IN;
}
}
sub queryDialog {
my ($self, $dialogRef, $patternRef, $msg, $queryFields) = @_;
if( not defined($$dialogRef) ) {
$$dialogRef = $self->rootWindow()->DialogBox(-title => "Lit UI", -buttons => ["OK", "Cancel"]);
$$dialogRef->LabEntry(-label => $msg,
-labelPack => [-side => "left", -anchor => "w"],
-textvariable => $patternRef)->pack(-expand => 1, -fill => 'x');
}
my $button = $$dialogRef->Show();
return if( $button eq "Cancel" );
my $pattern = $$patternRef;
return if( not defined($pattern) or $pattern eq "" );
my $q = new PBibTk::SearchDialog ($self, "$msg $pattern", "%$pattern%", $queryFields);
$q->show();
}
# show refs
sub showSelectedBiblioReference {
my $self = shift;
my $idx = $self->refListSelection();
return if !defined($idx) || $idx eq "";
my $paper = $self->litRefs()->queryPaperWithId($self->biblioRefAt($idx));
PBibTk::RefDialog->new($self, $paper)->show();
}
sub showSelectedPaperReference {
my $self = shift;
my $idx = $self->foundListSelection();
return if !defined($idx) || $idx eq "";
my $paper = $self->litRefs()->queryPaperWithId($self->paperRefAt($idx));
PBibTk::RefDialog->new($self, $paper)->show();
}
sub clipboardSelectedBiblioReferenceId {
my $self = shift;
my $idx = $self->refListSelection();
return if !defined($idx) || $idx eq "";
my $ref = $self->biblioRefAt($idx);
Win32::Clipboard()->Set("[$ref]");
}
sub clipboardSelectedPaperReferenceId {
my $self = shift;
my $idx = $self->foundListSelection();
return if !defined($idx) || $idx eq "";
my $ref = $self->paperRefAt($idx);
Win32::Clipboard()->Set("[$ref]");
}
sub searchSelectedBiblioReferenceId {
my $self = shift;
my $idx = $self->refListSelection();
return if !defined($idx) || $idx eq "";
$self->searchReferenceId($self->biblioRefAt($idx));
}
sub searchSelectedPaperReferenceId {
my $self = shift;
my $idx = $self->foundListSelection();
return if !defined($idx) || $idx eq "";
$self->searchReferenceId($self->paperRefAt($idx));
}
sub searchReferenceId {
my ($self, $ref) = @_;
# print "searchReferenceId {$filename, $ref)\n";
searchInFile($filename, "[$ref]") if $filename && $ref;
}
#myline runter ---------------------------------------------------
sub updateExpandedSelectedBiblioReference {
my ($self) = @_;
my $idx = $self->refListSelection();
return if !defined($idx) || $idx eq "";
my $paper = $self->litRefs()->queryPaperWithId($self->biblioRefAt($idx));
$self->updateExpandedSelectedReference($paper);
$self->{'refList'}->focus();
}
sub updateExpandedSelectedPaperReference {
my ($self) = @_;
my $idx = $self->foundListSelection();
return if !defined($idx) || $idx eq "";
my $paper = $self->litRefs()->queryPaperWithId($self->paperRefAt($idx));
$self->updateExpandedSelectedReference($paper);
$self->{'foundList'}->focus();
}
sub updateExpandedSelectedReference {
my ($self, $paper) = @_;
return if !defined($paper) || $paper eq "";
my @entry = PBibTk::RefDialog->new($self)->formatRefInfos($paper);
$self->chosenLabel()->configure(-label => $entry[0]);
my $list = $self->chosen();
$list->delete("0.0", "end");
$list->insert("end", $entry[1]);
}
sub chosen {
my $self = shift;
# access window first, to ensure it's created.
$self->window();
return $self->{'chosenfromlist'};
}
#myline hoch ---------------------------------------------------
( run in 0.858 second using v1.01-cache-2.11-cpan-84e82930d8c )