fix(TUP-21064)NPE happens when 'save as' routine https://jira.talendforge.org/browse/TUP-21064
This commit is contained in:
@@ -32,7 +32,6 @@ import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.draw2d.Cursors;
|
||||
import org.eclipse.draw2d.FigureCanvas;
|
||||
@@ -204,7 +203,6 @@ import org.talend.designer.core.ui.editor.connections.ConnLabelEditPart;
|
||||
import org.talend.designer.core.ui.editor.connections.Connection;
|
||||
import org.talend.designer.core.ui.editor.connections.ConnectionPart;
|
||||
import org.talend.designer.core.ui.editor.connections.NodeConnectorTool;
|
||||
import org.talend.designer.core.ui.editor.jobletcontainer.JobletContainer;
|
||||
import org.talend.designer.core.ui.editor.nodecontainer.NodeContainer;
|
||||
import org.talend.designer.core.ui.editor.nodes.Node;
|
||||
import org.talend.designer.core.ui.editor.nodes.NodePart;
|
||||
@@ -1186,6 +1184,7 @@ public abstract class AbstractTalendEditor extends GraphicalEditorWithFlyoutPale
|
||||
this.savePreviouslyNeeded = true;
|
||||
firePropertyChange(IEditorPart.PROP_DIRTY);
|
||||
}
|
||||
checkSaveAsEnabled();
|
||||
} else {
|
||||
savePreviouslyNeeded = false;
|
||||
firePropertyChange(IEditorPart.PROP_DIRTY);
|
||||
@@ -1193,6 +1192,21 @@ public abstract class AbstractTalendEditor extends GraphicalEditorWithFlyoutPale
|
||||
super.commandStackChanged(event);
|
||||
}
|
||||
|
||||
private void checkSaveAsEnabled() {
|
||||
if (!isSaveAsAllowed()) {
|
||||
return;
|
||||
}
|
||||
IAction action = getAction(ActionFactory.SAVE_AS.getId());
|
||||
if (action == null) {
|
||||
action = ActionFactory.SAVE_AS.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
|
||||
getActionRegistry().registerAction(action);
|
||||
}
|
||||
IAction saveAsAction = getAction(ActionFactory.SAVE_AS.getId());
|
||||
if (saveAsAction != null && !getAction(ActionFactory.SAVE_AS.getId()).isEnabled()) {
|
||||
getAction(ActionFactory.SAVE_AS.getId()).setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeErrorStatusIfDirty() {
|
||||
// remove all error status at any change of the job .
|
||||
IProcess2 process = getProcess();
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor;
|
||||
import org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor;
|
||||
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
|
||||
import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.text.source.ISourceViewer;
|
||||
@@ -58,6 +59,7 @@ import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorSite;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.actions.ActionFactory;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
@@ -418,9 +420,29 @@ public class StandAloneTalendJavaEditor extends CompilationUnitEditor implements
|
||||
if (!isEditable()) {
|
||||
return false;
|
||||
}
|
||||
return super.isDirty();
|
||||
boolean dirty = super.isDirty();
|
||||
if (dirty) {
|
||||
checkSaveAsEnabled();
|
||||
}
|
||||
return dirty;
|
||||
}
|
||||
|
||||
private void checkSaveAsEnabled() {
|
||||
if (!isSaveAsAllowed()) {
|
||||
return;
|
||||
}
|
||||
IAction action = getAction(ActionFactory.SAVE_AS.getId());
|
||||
if (action == null) {
|
||||
action = ActionFactory.SAVE_AS.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
|
||||
setAction(ActionFactory.SAVE_AS.getId(), action);
|
||||
}
|
||||
IAction saveAsAction = getAction(ActionFactory.SAVE_AS.getId());
|
||||
if (saveAsAction != null && !getAction(ActionFactory.SAVE_AS.getId()).isEnabled()) {
|
||||
getAction(ActionFactory.SAVE_AS.getId()).setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEditorInputReadOnly() {
|
||||
return !isEditable();
|
||||
@@ -730,6 +752,10 @@ public class StandAloneTalendJavaEditor extends CompilationUnitEditor implements
|
||||
|
||||
@Override
|
||||
public void doSaveAs() {
|
||||
// for the EditorInput of new created RepositoryNode, need to reload
|
||||
if (this.rEditorInput.getRepositoryNode() == null) {
|
||||
this.rEditorInput.setRepositoryNode(null);
|
||||
}
|
||||
ERepositoryObjectType type = this.rEditorInput.getRepositoryNode().getObject().getRepositoryObjectType();
|
||||
if (type == ERepositoryObjectType.ROUTINES) {
|
||||
SaveAsRoutineAction saveAsAction = new SaveAsRoutineAction(this);
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.talend.core.model.properties.ByteArray;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.properties.RoutineItem;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.designer.core.DesignerPlugin;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
@@ -108,12 +109,19 @@ public class SaveAsRoutineWizard extends Wizard {
|
||||
isUpdate = isUpdate();
|
||||
|
||||
if (isUpdate) {
|
||||
String originalLabel = oldProperty.getLabel();
|
||||
String originalVersion = oldProperty.getVersion();
|
||||
assginVlaues(oldProperty, property);
|
||||
|
||||
repositoryFactory.save(oldRoutineItem);
|
||||
repositoryFactory.save(oldProperty, originalLabel, originalVersion);
|
||||
|
||||
// assign value
|
||||
routineItem = oldRoutineItem;
|
||||
IRepositoryViewObject repObject = repositoryFactory.getSpecificVersion(oldProperty.getId(),
|
||||
oldProperty.getVersion(), true);
|
||||
if (repObject != null) {
|
||||
routineItem = (RoutineItem) repObject.getProperty().getItem();
|
||||
repObject.getProperty().eResource();
|
||||
}
|
||||
|
||||
} else {
|
||||
property.setId(repositoryFactory.getNextId());
|
||||
|
||||
Reference in New Issue
Block a user