use of org.eclipse.ui.IPropertyListener in project gfm_viewer by satyagraha.
the class MarkdownEditorTrackerTest method shouldNotNotifyOnEditorPartInput.
@Test
public void shouldNotNotifyOnEditorPartInput() throws Exception {
// given
given(editorPart.getEditorInput()).willReturn(editorInput);
willDoNothing().given(editorPart).addPropertyListener(propertyListenerCaptor.capture());
given(editorInput.getAdapter(IFile.class)).willReturn(editorIFile);
given(fileNature.isTrackableFile(editorIFile)).willReturn(true);
// when
editorTracker.start();
editorTracker.addListener(markdownListener);
editorTracker.editorShown(editorPart);
IPropertyListener propertyListener = propertyListenerCaptor.getValue();
given(editorPart.isDirty()).willReturn(false);
propertyListener.propertyChanged(editorPart, IEditorPart.PROP_INPUT);
// then
verify(markdownListener, times(1)).notifyEditorFile(editorIFile);
verifyNoMoreInteractions(markdownListener);
}
use of org.eclipse.ui.IPropertyListener in project gfm_viewer by satyagraha.
the class MarkdownEditorTrackerTest method shouldNotifyOnEditorPartSaved.
@Test
public void shouldNotifyOnEditorPartSaved() throws Exception {
// given
given(editorPart.getEditorInput()).willReturn(editorInput);
willDoNothing().given(editorPart).addPropertyListener(propertyListenerCaptor.capture());
given(editorInput.getAdapter(IFile.class)).willReturn(editorIFile);
given(fileNature.isTrackableFile(editorIFile)).willReturn(true);
// when
editorTracker.start();
editorTracker.addListener(markdownListener);
editorTracker.editorShown(editorPart);
IPropertyListener propertyListener = propertyListenerCaptor.getValue();
given(editorPart.isDirty()).willReturn(false);
propertyListener.propertyChanged(editorPart, IEditorPart.PROP_DIRTY);
// then
verify(markdownListener, times(2)).notifyEditorFile(editorIFile);
verifyNoMoreInteractions(markdownListener);
}
use of org.eclipse.ui.IPropertyListener in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method turnToJobScriptPage.
protected void turnToJobScriptPage(int newPageIndex) {
if (jobletEditor != getEditor(newPageIndex)) {
return;
}
ICreateXtextProcessService convertJobtoScriptService = CorePlugin.getDefault().getCreateXtextProcessService();
try {
final String scriptValue = convertJobtoScriptService.convertJobtoScript(getProcess().saveXmlFile());
IFile file = (IFile) jobletEditor.getEditorInput().getAdapter(IResource.class);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(scriptValue.getBytes());
if (file.exists()) {
jobletEditor.getDocumentProvider().getDocument(jobletEditor.getEditorInput()).set(scriptValue);
boolean isProcessReadOnly = ((JobEditorInput) getEditor(0).getEditorInput()).isReadOnly();
IProxyRepositoryFactory rFactory = ProxyRepositoryFactory.getInstance();
if (isProcessReadOnly || rFactory.isUserReadOnlyOnCurrentProject()) {
IDocumentProvider provider = jobletEditor.getDocumentProvider();
Class p = provider.getClass();
Class[] type = new Class[1];
type[0] = Boolean.TYPE;
Object[] para = new Object[1];
para[0] = Boolean.TRUE;
Method method = p.getMethod("setReadOnly", type);
method.invoke(provider, para);
}
//$NON-NLS-1$
IAction action = jobletEditor.getAction("FoldingRestore");
action.run();
jobletEditor.doSave(null);
} else {
file.create(byteArrayInputStream, true, null);
}
if (propertyListener == null) {
propertyListener = new IPropertyListener() {
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof IEditorPart && ((IEditorPart) source).isDirty()) {
getProcess().setProcessModified(true);
getProcess().setNeedRegenerateCode(true);
}
}
};
jobletEditor.addPropertyListener(propertyListener);
}
} catch (PartInitException e) {
ExceptionHandler.process(e);
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
} catch (SecurityException e) {
ExceptionHandler.process(e);
} catch (NoSuchMethodException e) {
ExceptionHandler.process(e);
} catch (IllegalArgumentException e) {
ExceptionHandler.process(e);
} catch (IllegalAccessException e) {
ExceptionHandler.process(e);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
}
changeContextsViewStatus(false);
}
use of org.eclipse.ui.IPropertyListener in project gfm_viewer by satyagraha.
the class MarkdownEditorTrackerTest method shouldNotNotifyOnEditorPartialSave.
@Test
public void shouldNotNotifyOnEditorPartialSave() throws Exception {
// given
given(editorPart.getEditorInput()).willReturn(editorInput);
willDoNothing().given(editorPart).addPropertyListener(propertyListenerCaptor.capture());
given(editorInput.getAdapter(IFile.class)).willReturn(editorIFile);
given(fileNature.isTrackableFile(editorIFile)).willReturn(true);
// when
editorTracker.start();
editorTracker.addListener(markdownListener);
editorTracker.editorShown(editorPart);
IPropertyListener propertyListener = propertyListenerCaptor.getValue();
given(editorPart.isDirty()).willReturn(true);
propertyListener.propertyChanged(editorPart, IEditorPart.PROP_DIRTY);
// then
verify(markdownListener, times(1)).notifyEditorFile(editorIFile);
verifyNoMoreInteractions(markdownListener);
}
Aggregations