@Override
	public int open(JoeTree tree, DocumentInfo docInfo, InputStream stream) {
		int success = FAILURE;
		
		String text = null;
		
		try {
			BufferedReader buf = new BufferedReader(new InputStreamReader(stream, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_ENCODING_TYPE)));
			
			StringBuffer sb = new StringBuffer();
			String s;
			while((s = buf.readLine()) != null) {
				sb.append(s).append(Preferences.LINE_END_STRING);
			}
			buf.close();
			
			text = sb.toString();
		} catch(IOException e) {
			e.printStackTrace();
		}
		
		if (text != null) {
			Node newNode = new NodeImpl(tree,"");
			int padSuccess = PadSelection.pad(text, tree, 0,PlatformCompatibility.LINE_END_UNIX, newNode);
			
			switch (padSuccess) {
				
				case PadSelection.SUCCESS:
					tree.setRootNode(newNode);
					success = SUCCESS;
					break;
					
				case PadSelection.SUCCESS_MODIFIED:
					String yes = GUITreeLoader.reg.getText("yes");
					String no = GUITreeLoader.reg.getText("no");
					String confirm_open = GUITreeLoader.reg.getText("confirm_open");
					String msg = GUITreeLoader.reg.getText("confirmation_inconsistent_hierarchy");
					msg = Replace.replace(msg,GUITreeComponentRegistry.PLACEHOLDER_1, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_PATH));
					
					
					Object[] options = {yes, no};
					int result = JOptionPane.showOptionDialog(
						Outliner.outliner,
						msg,
						confirm_open,
						JOptionPane.YES_NO_OPTION,
						JOptionPane.QUESTION_MESSAGE,
						null,
						options,
						options[0]
					);
					
					if (result == JOptionPane.YES_OPTION) {
						success = SUCCESS_MODIFIED;
						tree.setRootNode(newNode);
						break;
					} else if (result == JOptionPane.NO_OPTION) {
						success = FAILURE_USER_ABORTED;
						break;
					}
					
				case PadSelection.FAILURE:
					success = FAILURE;
					break;
			}
		} else {
			success = FAILURE;
		}
		
		return success;
	}