Autopsy  4.7.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
StatusIconCellRenderer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2015-2017 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.guiutils;
20 
21 import java.awt.Component;
22 import javax.swing.ImageIcon;
23 import javax.swing.JTable;
24 import static javax.swing.SwingConstants.CENTER;
25 import org.openide.util.ImageUtilities;
26 import org.openide.util.NbBundle.Messages;
27 
34 
35  private static final long serialVersionUID = 1L;
36  static final ImageIcon OK_ICON = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/tick.png", false));
37  static final ImageIcon WARNING_ICON = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/warning16.png", false));
38  static final ImageIcon ERROR_ICON = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/cross-script.png", false));
39 
40  @Messages({
41  "StatusIconCellRenderer.tooltiptext.ok=OK",
42  "StatusIconCellRenderer.tooltiptext.warning=A warning occurred",
43  "StatusIconCellRenderer.tooltiptext.error=An error occurred"
44  })
45  @Override
46  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
47  setHorizontalAlignment(CENTER);
48  if ((value instanceof Status)) {
49  switch((Status) value) {
50  case OK:
51  setIcon(OK_ICON);
52  setToolTipText(org.openide.util.NbBundle.getMessage(StatusIconCellRenderer.class, "StatusIconCellRenderer.tooltiptext.ok"));
53  break;
54  case WARNING:
55  setIcon(WARNING_ICON);
56  setToolTipText(org.openide.util.NbBundle.getMessage(StatusIconCellRenderer.class, "StatusIconCellRenderer.tooltiptext.warning"));
57  break;
58  case ERROR:
59  setIcon(ERROR_ICON);
60  setToolTipText(org.openide.util.NbBundle.getMessage(StatusIconCellRenderer.class, "StatusIconCellRenderer.tooltiptext.error"));
61  break;
62  }
63  }
64  else {
65  setIcon(null);
66  setText("");
67  }
68  grayCellIfTableNotEnabled(table, isSelected);
69 
70  return this;
71  }
72 
73  public enum Status {
74  OK,
76  ERROR
77  }
78 }
Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
void grayCellIfTableNotEnabled(JTable table, boolean isSelected)

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.