Projects STRLCPY LoggerPlusPlus Commits 96e205b6
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/tag/Tag.java
     1 +package com.nccgroup.loggerplusplus.filter.tag;
     2 + 
     3 +import com.nccgroup.loggerplusplus.filter.logfilter.LogFilter;
     4 +import com.nccgroup.loggerplusplus.filter.parser.ParseException;
     5 +import com.nccgroup.loggerplusplus.filterlibrary.FilterLibraryController;
     6 + 
     7 +import java.awt.*;
     8 +import java.util.UUID;
     9 + 
     10 +/**
     11 + * Created by corey on 19/07/17.
     12 + */
     13 +public class Tag implements Comparable<Tag> {
     14 + private UUID uid;
     15 + private String name;
     16 + private LogFilter filter;
     17 + private String filterString;
     18 + private Color backgroundColor;
     19 + private Color foregroundColor;
     20 + private boolean enabled;
     21 + private boolean modified;
     22 + private boolean shouldRetest;
     23 + private short priority;
     24 + 
     25 + public Tag() {
     26 + this.uid = UUID.randomUUID();
     27 + this.enabled = true;
     28 + this.shouldRetest = true;
     29 + }
     30 + 
     31 + public Tag(String title, LogFilter filter) {
     32 + this();
     33 + this.name = title;
     34 + this.setFilter(filter);
     35 + }
     36 + 
     37 + public Tag(FilterLibraryController filterLibraryController, String title, String filterString) throws ParseException {
     38 + this(title, new LogFilter(filterLibraryController, filterString));
     39 + }
     40 + 
     41 + public Tag(String title, LogFilter filter, Color foreground, Color background) {
     42 + this(title, filter);
     43 + this.foregroundColor = foreground;
     44 + this.backgroundColor = background;
     45 + }
     46 + 
     47 + public UUID getUUID() {
     48 + return uid;
     49 + }
     50 + 
     51 + public void setBackgroundColor(Color backgroundColor) {
     52 + this.backgroundColor = backgroundColor;
     53 + this.modified = true;
     54 + }
     55 + 
     56 + public Color getBackgroundColor() {
     57 + return backgroundColor;
     58 + }
     59 + 
     60 + public Color getForegroundColor() {
     61 + return foregroundColor;
     62 + }
     63 + 
     64 + public void setForegroundColor(Color foregroundColor) {
     65 + this.foregroundColor = foregroundColor;
     66 + modified = true;
     67 + }
     68 + 
     69 + public LogFilter getFilter() {
     70 + return filter;
     71 + }
     72 + 
     73 + public void setFilter(LogFilter filter) {
     74 + this.filter = filter;
     75 + if (filter != null)
     76 + this.filterString = filter.toString();
     77 + modified = true;
     78 + shouldRetest = true;
     79 + }
     80 + 
     81 + public String getName() {
     82 + return name;
     83 + }
     84 + 
     85 + public void setName(String name) {
     86 + this.name = name;
     87 + }
     88 + 
     89 + public boolean isEnabled() {
     90 + return enabled;
     91 + }
     92 + 
     93 + public void setEnabled(boolean enabled) {
     94 + this.enabled = enabled;
     95 + modified = true;
     96 + shouldRetest = true;
     97 + }
     98 + 
     99 + public String getFilterString() {
     100 + return filterString;
     101 + }
     102 + 
     103 + public void setFilterString(String filterString) {
     104 + this.filterString = filterString;
     105 + }
     106 + 
     107 + public boolean equals(Object obj) {
     108 + if (obj instanceof Tag) {
     109 + return ((Tag) obj).getUUID().equals(this.uid);
     110 + } else {
     111 + return super.equals(obj);
     112 + }
     113 + }
     114 + 
     115 + public boolean isModified() {
     116 + return modified;
     117 + }
     118 + 
     119 + public void setModified(boolean modified) {
     120 + this.modified = modified;
     121 + }
     122 + 
     123 + public void setPriority(short priority) {
     124 + this.priority = priority;
     125 + this.modified = true;
     126 + }
     127 + 
     128 + public short getPriority() {
     129 + return priority;
     130 + }
     131 + 
     132 + @Override
     133 + public int compareTo(Tag tag) {
     134 + return ((Comparable) this.priority).compareTo(tag.getPriority());
     135 + }
     136 + 
     137 + public boolean shouldRetest() {
     138 + return shouldRetest;
     139 + }
     140 + 
     141 + @Override
     142 + public String toString() {
     143 + return "ColorFilter[" + (this.filter != null ? this.filter.toString() : "") + "]";
     144 + }
     145 +}
     146 + 
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/tag/TagListener.java
     1 +package com.nccgroup.loggerplusplus.filter.tag;
     2 + 
     3 +/**
     4 + * Created by corey on 20/07/17.
     5 + */
     6 +public interface TagListener {
     7 + 
     8 + void onTagChange(Tag filter);
     9 + 
     10 + void onTagAdd(Tag filter);
     11 + 
     12 + void onTagRemove(Tag filter);
     13 +}
     14 + 
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/util/userinterface/dialog/TagTable.java
     1 +package com.nccgroup.loggerplusplus.util.userinterface.dialog;
     2 + 
     3 +import com.nccgroup.loggerplusplus.filter.tag.Tag;
     4 +import com.nccgroup.loggerplusplus.filterlibrary.FilterLibraryController;
     5 +import com.nccgroup.loggerplusplus.util.userinterface.renderer.ButtonRenderer;
     6 +import com.nccgroup.loggerplusplus.util.userinterface.renderer.FilterRenderer;
     7 + 
     8 +import javax.swing.*;
     9 +import java.awt.*;
     10 +import java.awt.event.MouseAdapter;
     11 +import java.awt.event.MouseEvent;
     12 + 
     13 +/**
     14 + * Created by corey on 19/07/17.
     15 + */
     16 +public class TagTable extends JTable {
     17 + private final FilterLibraryController filterLibraryController;
     18 + 
     19 + TagTable(FilterLibraryController filterLibraryController) {
     20 + this.filterLibraryController = filterLibraryController;
     21 + this.setModel(new TagTableModel(filterLibraryController));
     22 + this.setFillsViewportHeight(true);
     23 + this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
     24 + this.setAutoCreateRowSorter(false);
     25 + this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     26 + this.setRowHeight(25);
     27 + ((JComponent) this.getDefaultRenderer(Boolean.class)).setOpaque(true); // to remove the white background of the checkboxes!
     28 + ((JComponent) this.getDefaultRenderer(JButton.class)).setOpaque(true);
     29 + 
     30 + this.getColumnModel().getColumn(1).setCellRenderer(new FilterRenderer());
     31 + this.getColumnModel().getColumn(3).setCellRenderer(new ButtonRenderer());
     32 + 
     33 + 
     34 + this.setDragEnabled(true);
     35 + this.setDropMode(DropMode.INSERT);
     36 + 
     37 + int[] minWidths = {100, 250, 100, 100};
     38 + for (int i = 0; i < minWidths.length; i++) {
     39 + this.getColumnModel().getColumn(i).setMinWidth(minWidths[i]);
     40 + }
     41 + int[] maxWidths = {9999, 9999, 100, 100};
     42 + for (int i = 0; i < maxWidths.length; i++) {
     43 + this.getColumnModel().getColumn(i).setMaxWidth(maxWidths[i]);
     44 + }
     45 + this.setMinimumSize(new Dimension(850, 200));
     46 + 
     47 + final JTable _this = this;
     48 + this.addMouseListener(new MouseAdapter() {
     49 + @Override
     50 + public void mouseReleased(MouseEvent mouseEvent) {
     51 + if (SwingUtilities.isLeftMouseButton(mouseEvent)) {
     52 + int col = _this.columnAtPoint(mouseEvent.getPoint());
     53 + int row = _this.rowAtPoint(mouseEvent.getPoint());
     54 + ((TagTableModel) getModel()).onClick(row, col);
     55 + }
     56 + }
     57 + });
     58 + }
     59 + 
     60 + public void moveSelectedUp() {
     61 + if (this.getSelectedRow() > 0) {
     62 + ((TagTableModel) this.getModel()).switchRows(this.getSelectedRow(), this.getSelectedRow() - 1);
     63 + this.getSelectionModel().setSelectionInterval(this.getSelectedRow() - 1, this.getSelectedRow() - 1);
     64 + Tag filter = ((TagTableModel) this.getModel()).getTagAtRow(this.getSelectedRow());
     65 + filterLibraryController.updateTag(filter);
     66 + }
     67 + }
     68 + 
     69 + public void moveSelectedDown() {
     70 + if (this.getSelectedRow() >= 0 && this.getSelectedRow() < this.getRowCount()) {
     71 + ((TagTableModel) this.getModel()).switchRows(this.getSelectedRow(), this.getSelectedRow() + 1);
     72 + this.getSelectionModel().setSelectionInterval(this.getSelectedRow() + 1, this.getSelectedRow() + 1);
     73 + Tag filter = ((TagTableModel) this.getModel()).getTagAtRow(this.getSelectedRow());
     74 + filterLibraryController.updateTag(filter);
     75 + }
     76 + }
     77 +}
     78 + 
Please wait...
Page is in error, reload to recover