package org.cytoscape.task.internal.table;

/*
 * #%L
 * Cytoscape Core Task Impl (core-task-impl)
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2010 - 2013 The Cytoscape Consortium
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 2.1 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
 * #L%
 */


import org.cytoscape.model.CyColumn;
import org.cytoscape.model.CyTable;
import org.cytoscape.task.AbstractTableColumnTask;
import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.Tunable;
import org.cytoscape.work.TunableValidator;
import org.cytoscape.work.TunableValidator.ValidationState;
import org.cytoscape.work.undo.UndoSupport;


public final class DeleteColumnTask extends AbstractTableColumnTask implements TunableValidator {
	private final UndoSupport undoSupport;

	DeleteColumnTask(final UndoSupport undoSupport, final CyColumn column) {
		super(column);
		this.undoSupport = undoSupport;
	}

	@Override
	public void run(final TaskMonitor taskMonitor) throws Exception {
		taskMonitor.setProgress(0.0);
		undoSupport.postEdit(
			new DeleteColumnEdit(column));
		taskMonitor.setProgress(0.3);
		column.getTable().deleteColumn(column.getName());
		taskMonitor.setProgress(1.0);
	}

	@Override
	public ValidationState getValidationState(final Appendable errMsg) {
		if (column.isImmutable()) {
			try {
				errMsg.append("Cannot delete an immutable column.");
			} catch (Exception e) {
			}
			return ValidationState.INVALID;
		}

		return ValidationState.OK;
	}
}
@@ -1230,16 +1230,51 @@
 upport;%0A
+import javax.swing.SwingUtilities;%0A
 %0A%0Apublic
@@ -1737,16 +1737,106 @@
 0.3);%0A%09%09
+SwingUtilities.invokeLater(new Runnable() %7B%0A%0A            public void run() %7B%0A            %09
 column.g
@@ -1873,24 +1873,50 @@
 getName());%0A
+            %7D%0A        %7D);%0A
 %09%09taskMonito

Fix bug #1665. Add a swingUtilities invokeLater to avoid thread conflicts with swing.