Subversion Repositories gelsvn

Rev

Rev 217 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 217 Rev 259
1
package HTMLProjectCreator;
1
package HTMLProjectCreator;
2
 
2
 
3
# ************************************************************
3
# ************************************************************
4
# Description   : An HTML project creator to display all settings
4
# Description   : An HTML project creator to display all settings
5
# Author        : Justin Michel & Chad Elliott
5
# Author        : Justin Michel & Chad Elliott
6
# Create Date   : 8/25/2003
6
# Create Date   : 8/25/2003
7
# ************************************************************
7
# ************************************************************
8
 
8
 
9
# ************************************************************
9
# ************************************************************
10
# Pragmas
10
# Pragmas
11
# ************************************************************
11
# ************************************************************
12
 
12
 
13
use strict;
13
use strict;
14
 
14
 
15
use ProjectCreator;
15
use ProjectCreator;
16
use XMLProjectBase;
16
use XMLProjectBase;
17
 
17
 
18
use vars qw(@ISA);
18
use vars qw(@ISA);
19
@ISA = qw(XMLProjectBase ProjectCreator);
19
@ISA = qw(XMLProjectBase ProjectCreator);
20
 
20
 
21
# ************************************************************
21
# ************************************************************
22
# Data Section
22
# Data Section
23
# ************************************************************
23
# ************************************************************
24
 
24
 
25
my($style_indent) = .5;
25
my($style_indent) = .5;
26
 
26
 
27
# ************************************************************
27
# ************************************************************
28
# Subroutine Section
28
# Subroutine Section
29
# ************************************************************
29
# ************************************************************
30
 
30
 
31
sub file_sorter {
31
sub file_sorter {
32
  #my($self)  = shift;
32
  #my($self)  = shift;
33
  #my($left)  = shift;
33
  #my($left)  = shift;
34
  #my($right) = shift;
34
  #my($right) = shift;
35
  return lc($_[1]) cmp lc($_[2]);
35
  return lc($_[1]) cmp lc($_[2]);
36
}
36
}
37
 
37
 
38
 
38
 
39
sub label_nodes {
39
sub label_nodes {
40
  my($self)  = shift;
40
  my($self)  = shift;
41
  my($hash)  = shift;
41
  my($hash)  = shift;
42
  my($nodes) = shift;
42
  my($nodes) = shift;
43
  my($level) = shift;
43
  my($level) = shift;
44
 
44
 
45
  foreach my $key (sort keys %$hash) {
45
  foreach my $key (sort keys %$hash) {
46
    push(@$nodes, [$level, $key]);
46
    push(@$nodes, [$level, $key]);
47
    $self->label_nodes($$hash{$key}, $nodes, $level + 1);
47
    $self->label_nodes($$hash{$key}, $nodes, $level + 1);
48
  }
48
  }
49
}
49
}
50
 
50
 
51
 
51
 
52
sub count_levels {
52
sub count_levels {
53
  my($self)    = shift;
53
  my($self)    = shift;
54
  my($hash)    = shift;
54
  my($hash)    = shift;
55
  my($current) = shift;
55
  my($current) = shift;
56
  my($count)   = shift;
56
  my($count)   = shift;
57
 
57
 
58
  foreach my $key (keys %$hash) {
58
  foreach my $key (keys %$hash) {
59
    $self->count_levels($$hash{$key}, $current + 1, $count);
59
    $self->count_levels($$hash{$key}, $current + 1, $count);
60
  }
60
  }
61
  if ($current > $$count) {
61
  if ($current > $$count) {
62
    $$count = $current;
62
    $$count = $current;
63
  }
63
  }
64
}
64
}
65
 
65
 
66
 
66
 
67
sub fill_value {
67
sub fill_value {
68
  my($self)  = shift;
68
  my($self)  = shift;
69
  my($name)  = shift;
69
  my($name)  = shift;
70
  my($value) = undef;
70
  my($value) = undef;
71
 
71
 
72
  if ($name eq 'inheritance_nodes') {
72
  if ($name eq 'inheritance_nodes') {
73
    ## Get the nodes with numeric labels for the level
73
    ## Get the nodes with numeric labels for the level
74
    my(@nodes) = ();
74
    my(@nodes) = ();
75
    $self->label_nodes($self->get_inheritance_tree(), \@nodes, 0);
75
    $self->label_nodes($self->get_inheritance_tree(), \@nodes, 0);
76
 
76
 
77
    ## Push each node onto the value array
77
    ## Push each node onto the value array
78
    $value = [];
78
    $value = [];
79
    for(my $i = 0; $i <= $#nodes; ++$i) {
79
    for(my $i = 0; $i <= $#nodes; ++$i) {
80
      my($file) = $nodes[$i]->[1];
80
      my($file) = $nodes[$i]->[1];
81
      my($dir)  = $self->mpc_dirname($file);
81
      my($dir)  = $self->mpc_dirname($file);
82
      my($base) = $self->mpc_basename($file);
82
      my($base) = $self->mpc_basename($file);
83
 
83
 
84
      ## Relative paths do not work at all in a web browser
84
      ## Relative paths do not work at all in a web browser
85
      if ($dir eq '.') {
85
      if ($dir eq '.') {
86
        $file = $base;
86
        $file = $base;
87
      }
87
      }
88
 
88
 
89
      my($path) = ($base eq $file ? $self->getcwd() . '/' : '');
89
      my($path) = ($base eq $file ? $self->getcwd() . '/' : '');
90
      my($name) = undef;
90
      my($name) = undef;
91
 
91
 
92
      if ($i == 0) {
92
      if ($i == 0) {
93
        ## If this is the first node, then replace the base filename
93
        ## If this is the first node, then replace the base filename
94
        ## with the actual project name.
94
        ## with the actual project name.
95
        $name = $self->project_name();
95
        $name = $self->project_name();
96
      }
96
      }
97
      else {
97
      else {
98
        ## This is a base project, so we use the basename and
98
        ## This is a base project, so we use the basename and
99
        ## remove the file extension.
99
        ## remove the file extension.
100
        $name = $base;
100
        $name = $base;
101
        $name =~ s/\.[^\.]+$//;
101
        $name =~ s/\.[^\.]+$//;
102
      }
102
      }
103
 
103
 
104
      ## Create the div and a tags.
104
      ## Create the div and a tags.
105
      push(@$value, '<a href="file://' . $path . $file .
105
      push(@$value, '<a href="file://' . $path . $file .
106
                    '" onClick="return popup(this, \'Project File\')" ' .
106
                    '" onClick="return popup(this, \'Project File\')" ' .
107
                    'target=_blank>' .
107
                    'target=_blank>' .
108
                    '<div class="tree' . $nodes[$i]->[0] . '">' .
108
                    '<div class="tree' . $nodes[$i]->[0] . '">' .
109
                     $name . '</div></a>');
109
                     $name . '</div></a>');
110
    }
110
    }
111
  }
111
  }
112
  elsif ($name eq 'tree_styles') {
112
  elsif ($name eq 'tree_styles') {
113
    ## Count the number of levels deep the inheritance goes
113
    ## Count the number of levels deep the inheritance goes
114
    my($count) = 0;
114
    my($count) = 0;
115
    $self->count_levels($self->get_inheritance_tree(), 0, \$count);
115
    $self->count_levels($self->get_inheritance_tree(), 0, \$count);
116
 
116
 
117
    my($margin) = 0;
117
    my($margin) = 0;
118
    my($start)  = 100;
118
    my($start)  = 100;
119
    my($max)    = 255;
119
    my($max)    = 255;
120
    my($inc)    = ($count ne 0 ? int(($max - $start) / $count) : $max);
120
    my($inc)    = ($count ne 0 ? int(($max - $start) / $count) : $max);
121
 
121
 
122
    ## Push each tree style onto the value array
122
    ## Push each tree style onto the value array
123
    $value = [];
123
    $value = [];
124
    for(my $i = 0; $i < $count; ++$i) {
124
    for(my $i = 0; $i < $count; ++$i) {
125
      push(@$value, ".tree$i { background-color: #" .
125
      push(@$value, ".tree$i { background-color: #" .
126
                    sprintf("%02x%02x%02x", 0, $start, $start) . ';' .
126
                    sprintf("%02x%02x%02x", 0, $start, $start) . ';' .
127
                    ($margin != 0 ? " margin-left: $margin" . 'in;' : '') .
127
                    ($margin != 0 ? " margin-left: $margin" . 'in;' : '') .
128
                    ' }');
128
                    ' }');
129
      $start += $inc;
129
      $start += $inc;
130
      $margin += $style_indent;
130
      $margin += $style_indent;
131
    }
131
    }
132
  }
132
  }
133
 
133
 
134
  return $value;
134
  return $value;
135
}
135
}
136
 
136
 
137
 
137
 
138
sub project_file_extension {
138
sub project_file_extension {
139
  #my($self) = shift;
139
  #my($self) = shift;
140
  return '.html';
140
  return '.html';
141
}
141
}
142
 
142
 
143
 
143
 
144
1;
144
1;
145
 
145