private void updateTableFromTextEditor() {
		
		tableHeaderMenu = new Menu(tableViewer.getTable());
		
		// PropertyFile propertyFile = (PropertyFile) treeViewer.getInput();
		model.removeModelListener(csvFileListener);

		model.setInput(editor.getDocumentProvider()
				.getDocument(editor.getEditorInput()).get());

		final MenuItem detailedEditItem = new MenuItem(tableHeaderMenu,
				SWT.PUSH, 0);
		detailedEditItem.setText("Edit");
		detailedEditItem.setSelection(false);
		detailedEditItem.addListener(SWT.Selection, new Listener() {
			
			public void handleEvent(Event event) {
				
				CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
				
				if(row != null){
					DetailedEditor input = new DetailedEditor(Display.getDefault(), model.getHeader(), 
							row, model.getInCellDelimiter(), model.getRegexTableMarker());
					input.open();
				}
			}
		});
		
		new MenuItem(tableHeaderMenu, SWT.SEPARATOR, 1);

		TableColumn[] columns = tableViewer.getTable().getColumns();
		if (columns.length > 0) { // if table header columns already created
			// update column header text
			for (int i = 0; i < model.getHeader().size(); i++){
				if(i < columns.length){
					columns[i].setText(model.getHeader().get(i));
					final int index = i;
					addMenuItemToColumn(columns[i], index+2);
				}
			}
		} else {
			// create columns
			for (int i = 0; i < model.getHeader().size(); i++) {
				final TableViewerColumn column = new TableViewerColumn(
						tableViewer, SWT.LEFT);
				final int index = i;
				column.getColumn().setText(model.getHeader().get(i));
				column.getColumn().setWidth(100);
				column.getColumn().setResizable(true);
				column.getColumn().setMoveable(true);
				column.setLabelProvider(new CSVLabelProvider());
				//+2 because the first two items are Edit and a separator
				addMenuItemToColumn(column.getColumn(), index+2);
			}
		}

		if (model.isFirstLineHeader()) {
			new MenuItem(tableHeaderMenu, SWT.SEPARATOR);

			// create menu item to delete column
			final MenuItem deleteColumnItem = new MenuItem(tableHeaderMenu,
					SWT.PUSH);
			deleteColumnItem.setText("Delete Column");
			deleteColumnItem.setSelection(false);
			deleteColumnItem.addListener(SWT.Selection, new Listener() {
				public void handleEvent(Event event) {
					// call delete column page
					DeleteColumnPage dcPage = new DeleteColumnPage(getSite()
							.getShell(), model.getArrayHeader());
					if (dcPage.open() == InputDialog.OK) {
						String[] colToDelete = dcPage.getColumnSelected();
						for (String column : colToDelete) {
							int colIndex = findColumnForName(column);
							tableViewer.getTable().getColumn(colIndex)
									.dispose();
							//+2 because the first two items are Edit and a separator
							tableHeaderMenu.getItem(colIndex+2).dispose();
							model.removeColumn(column);
						}
						tableModified();
					}
				}
			});

			// create menu item to insert column
			final MenuItem insertColumnItem = new MenuItem(tableHeaderMenu,
					SWT.PUSH);
			insertColumnItem.setText("Add Column");
			insertColumnItem.setSelection(false);
			insertColumnItem.addListener(SWT.Selection, new Listener() {
				public void handleEvent(Event event) {
					// call insert/add column page
					InsertColumnPage acPage = new InsertColumnPage(getSite()
							.getShell(), model.getArrayHeader());
					if (acPage.open() == InputDialog.OK) {
						String colToInsert = acPage.getColumnNewName();
						model.addColumn(colToInsert);

						tableViewer.setInput(model);
						final TableColumn column = new TableColumn(tableViewer
								.getTable(), SWT.LEFT);
						column.setText(colToInsert);
						column.setWidth(100);
						column.setResizable(true);
						column.setMoveable(true);

						addMenuItemToColumn(column, model.getColumnCount() - 1);
						defineCellEditing();

						tableModified();
					}
				}
			});
		}

		tableViewer.setInput(model);
		model.addModelListener(csvFileListener);

		tableViewer.getTable().addListener(SWT.MenuDetect, new Listener() {
			public void handleEvent(Event event) {
				tableViewer.getTable().setMenu(tableHeaderMenu);
			}
		});

		defineCellEditing();
	}