001/* 002 * Copyright 2010-2015 Institut Pasteur. 003 * 004 * This file is part of Icy. 005 * 006 * Icy is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Icy is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Icy. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package icy.gui.main; 020 021/** 022 * @deprecated Use {@link GlobalOverlayListener}, {@link GlobalPluginListener}, 023 * {@link GlobalROIListener}, {@link GlobalSequenceListener} and 024 * {@link GlobalViewerListener} interface instead. 025 * @author Stephane 026 */ 027public class MainEvent 028{ 029 public enum MainEventSourceType 030 { 031 PLUGIN, VIEWER, SEQUENCE, ROI, PAINTER 032 } 033 034 public enum MainEventType 035 { 036 OPENED, FOCUSED, CLOSED, ADDED, REMOVED 037 } 038 039 private final MainEventSourceType sourceType; 040 private final MainEventType type; 041 private Object source; 042 043 public MainEvent(MainEventSourceType sourceType, MainEventType type, Object source) 044 { 045 super(); 046 047 this.sourceType = sourceType; 048 this.type = type; 049 this.source = source; 050 } 051 052 /** 053 * @return the source 054 */ 055 public Object getSource() 056 { 057 return source; 058 } 059 060 /** 061 * @return the sourceType 062 */ 063 public MainEventSourceType getSourceType() 064 { 065 return sourceType; 066 } 067 068 /** 069 * @return the type 070 */ 071 public MainEventType getType() 072 { 073 return type; 074 } 075 076 // /** 077 // * collapse with specified event 078 // */ 079 // public void collapse(MainEvent event) 080 // { 081 // // just use last source for focused event type 082 // if (type == MainEventType.FOCUSED) 083 // source = event.getSource(); 084 // } 085 // 086 // @Override 087// public int hashCode() 088// { 089// return sourceType.hashCode() ^ type.hashCode(); 090// } 091// 092// @Override 093// public boolean equals(Object obj) 094// { 095// if (obj instanceof MainEvent) 096// { 097// final MainEvent e = (MainEvent) obj; 098// 099// // same source type and same type 100// return (e.getSourceType() == sourceType) && (e.getType() == type) 101// && ((type == MainEventType.FOCUSED) || (e.getSource() == source)); 102// } 103// 104// return super.equals(obj); 105// } 106 107 @Override 108 public String toString() 109 { 110 return "Source = " + source + "; SourceType = " + sourceType + "; type = " + type; 111 } 112}