1 11 package org.eclipse.ui.part; 12 13 import java.util.Arrays ; 14 15 import org.eclipse.core.runtime.Assert; 16 import org.eclipse.jface.resource.ImageDescriptor; 17 import org.eclipse.ui.IEditorInput; 18 import org.eclipse.ui.IPersistableElement; 19 20 26 public class MultiEditorInput implements IEditorInput { 27 28 IEditorInput input[]; 29 30 String editors[]; 31 32 35 public MultiEditorInput(String [] editorIDs, IEditorInput[] innerEditors) { 36 Assert.isNotNull(editorIDs); 37 Assert.isNotNull(innerEditors); 38 editors = editorIDs; 39 input = innerEditors; 40 } 41 42 45 public IEditorInput[] getInput() { 46 return input; 47 } 48 49 52 public String [] getEditors() { 53 return editors; 54 } 55 56 59 public boolean exists() { 60 return true; 61 } 62 63 66 public ImageDescriptor getImageDescriptor() { 67 return null; 68 } 69 70 73 public String getName() { 74 String name = ""; for (int i = 0; i < (input.length - 1); i++) { 76 name = name + input[i].getName() + "/"; } 78 name = name + input[input.length - 1].getName(); 79 return name; 80 } 81 82 85 public IPersistableElement getPersistable() { 86 return null; 87 } 88 89 92 public String getToolTipText() { 93 return getName(); 94 } 95 96 99 public Object getAdapter(Class adapter) { 100 return null; 101 } 102 103 104 107 public boolean equals(Object obj) { 108 if (this == obj) { 109 return true; 110 } 111 if (!(obj instanceof MultiEditorInput)) { 112 return false; 113 } 114 MultiEditorInput other = (MultiEditorInput) obj; 115 return Arrays.equals(this.editors, other.editors) && Arrays.equals(this.input, other.input); 116 } 117 118 119 122 public int hashCode() { 123 int hash = 0; 124 for (int i = 0; i < editors.length; i++) { 125 hash = hash * 37 + editors[i].hashCode(); 126 } 127 for (int i = 0; i < input.length; i++) { 128 hash = hash * 37 + input[i].hashCode(); 129 } 130 return hash; 131 } 132 } 133 | Popular Tags |