Bundle-PBib

 view release on metacpan or  search on metacpan

lib/PBibTk/SearchDialog.pm  view on Meta::CPAN

}
sub selectedBiblioReference {
  my $self = shift;
  my $list = $self->resultList();
  my $idx = $list->curselection();
  return if !defined($idx) || $idx eq "";
  my $paper = $self->{'results'}->[$idx];
  return $paper;
#  print Dumper $paper;
}
sub chosenLabel { my $self = shift; return $self->{'searchchosen'}; }
sub chosen {
  my $self = shift;
  # access window first, to ensure it's created.
  $self->window();
  return $self->{'chosenfromlist'};
}
#myline hoch ---------------------------------------------------

sub initMenu {
  my ($self, $mf, $win) = @_;
  $self->pBibTkUI()->initBiblioMenu($mf, $win, $self);
}


sub resultList { return shift->{'resultList'}; }
sub refList { return shift->resultList(); }


#
# menu command methods
#

sub keyPressed {
  my ($self, $key, $mod) = @_;
  return if $mod && $mod ne '';
  my $list = $self->resultList();
  my $idx = $self->indexOfRefStartingWith($key); ##ord($key) - ord('a');
print "keyPressed $key ($mod) --> $idx\n";
  $list->selectionClear(0, 'end');
  $list->see($idx);
  $list->activate($idx);
  $list->selectionAnchor($idx);
  $list->selectionSet($idx);
}

sub selectionMove {
	# called on UP and Down key presses to be able to adjust the printed ref.
	my ($self, $list, $inc) = @_;
	$self->updateExpandedSelectedReference();
}

sub showSelectedBiblioReference {
	my $self = shift;
	my $paper = $self->selectedBiblioReference();
	return unless defined($paper);
	PBibTk::RefDialog
	  ->new($self->pBibTkUI(), $paper)
	  ->show();
}
sub clipboardSelectedBiblioReferenceId {
	my $self = shift;
	my $paper = $self->selectedBiblioReference();
	return unless defined($paper);
	my $ref = $paper->{'CiteKey'};
	Win32::Clipboard()->Set("[$ref]");
}
sub searchSelectedBiblioReferenceId {
	my $self = shift;
	my $paper = $self->selectedBiblioReference();
	return unless defined($paper);
	$self->pBibTkUI()->searchReferenceId($paper->{'CiteKey'});
}
sub queryAuthor {  my $self = shift;
  $self->pBibTkUI()->queryAuthor();
}
sub queryKeyword {  my $self = shift;
  $self->pBibTkUI()->queryKeyword();
}
sub updateBiblioRefs {  my $self = shift;
  $self->updateResults();
}


#
# updating
#


sub updateResults {
  my $self = shift;
  my $list = $self->resultList();
  $list->delete(0, "end");
  my $papers = $self->biblio()->queryPapers($self->pattern(),
	$self->queryFields(), $self->resultFields());
  $self->{'refs'} = $papers;
  my ($ref, $id, @results);
  my @refIDs = sort(keys %$papers);
  foreach $id (@refIDs) {
    $ref = $papers->{$id};
	push @results, $ref;
    my $key = $ref->{'CiteKey'} || '<<no CiteKey!?>>';
    my $cat = $ref->{'Category'} || '<<no Category>>';
    my $title = $ref->{'Title'} || '';
    my $author = $ref->{'Authors'} || $ref->{'Editors'} || $ref->{'Organization'} || '';
    my $recom = $ref->{'Recommendation'};
    my $year = $ref->{'Year'} || '';
	if( length($title) > $maxlength_title )
	  { $title = substr($title, 0, $maxlength_title) . ' ...' }
	if( $author ) {
	  if( length($author) > $maxlength_author )
	    { $author = substr($author, 0, $maxlength_author) . ' ...' }
	  if( $year )
	    { $author .= ', '; }
	}
    my $text = $key . ($recom ? " ($recom)" : '') . " \"$title\" ($author$year) [$cat]";
    $list->insert("end", $text);
  }
  $self->{'results'} = \@results;
  $self->window()->configure(
	-title => $self->title() . ' (' . scalar(@results) . ' found)',



( run in 1.957 second using v1.01-cache-2.11-cpan-84e82930d8c )