Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Open Atl Editor Through Line Code
Open Atl Editor Through Line Code [message #77570] Wed, 26 March 2008 18:47 Go to next message
Eclipse UserFriend
Originally posted by: narciso.martins.yahoo.com.br

Hello,
I couldn't find any topics about executing actions of Atl plugin through
java code. Could someone help me out?
I would like to open the Atl Editor on Eclipse throgh java code.


Best regards,

Narciso Martins
Re: Open Atl Editor Through Line Code [message #77676 is a reply to message #77570] Thu, 27 March 2008 13:29 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 297
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020306050705070100040701
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hello,

I think that your question is related to Eclipse more than ATL.
ATL editor inherits from the basic Eclipse's TextEditor, so you may have
to look how to launch that kind of editors programmatically.
Then you will be able to launch AtlEditor
(org.eclipse.m2m.atl.adt.ui.editor.AtlEditor class) as any other TextEditor.

Best Regards,

William

Narciso Martins a
Re: Open Atl Editor Through Line Code [message #80006 is a reply to message #77676] Thu, 24 April 2008 17:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: narciso.martins.yahoo.com.br

Actually, I want to open the ATL editor in a RCP application. I've added
the ATL plugins to my project but when I try to open the ATL editor I get
this error message:

org.eclipse.core.runtime.CoreException: Text editor does not have a
document provider (...)

Well, to open a text editor I use a class called OpenAction that calls the
text editor itself. So to open the class that you mentioned "AtlEditor" I
would have to have a class like the "OpenAction" one, right? So if it's
right, which class is that?

Thank you,

best regards!


Narciso Martins.
[ATL] Re: Open Atl Editor Through Line Code [message #80021 is a reply to message #77676] Thu, 24 April 2008 18:43 Go to previous message
Eclipse UserFriend
Originally posted by: narciso.martins.yahoo.com.br

Hey, it's me again!

The class that I talked about in the last message that I sent you is this
one:
I use this class to open text editors, XML editors and HTML editors.



package org.eclipse.ui.examples.rcp.texteditor.actions;

import java.io.File;
import java.text.MessageFormat;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;

import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.examples.rcp.texteditor.editors.PathEditorInp ut;

/**
* @since 3.0
*/
public class OpenFileAction extends Action implements
IWorkbenchWindowActionDelegate {

private IWorkbenchWindow fWindow;

public OpenFileAction() {
setEnabled(true);
}

/*
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/
public void dispose() {
fWindow= null;
}

/*
* @see
org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclip se.ui.IWorkbenchWindow)
*/
public void init(IWorkbenchWindow window) {
fWindow= window;
}

/*
* @see
org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action. IAction)
*/
public void run(IAction action) {
run();
}

/*
* @see
org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse. jface.action.IAction,
org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}

private File queryFile() {
FileDialog dialog= new FileDialog(fWindow.getShell(), SWT.OPEN);
dialog.setText("Open File"); //$NON-NLS-1$
String path= dialog.open();
if (path != null && path.length() > 0)
return new File(path);
return null;
}

/*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
File file= queryFile();
if (file != null) {
IEditorInput input= createEditorInput(file);
String editorId= getEditorId(file);
IWorkbenchPage page= fWindow.getActivePage();
try {
page.openEditor(input, editorId);
} catch (PartInitException e) {
e.printStackTrace();
}
} else if (file != null) {
String msg = MessageFormat.format("File is null: {0}", new String[]
{file.getName()}); //$NON-NLS-1$
MessageDialog.openWarning(fWindow.getShell(), "Problem", msg);
//$NON-NLS-1$
}
}

private String getEditorId(File file) {
IWorkbench workbench= fWindow.getWorkbench();
IEditorRegistry editorRegistry= workbench.getEditorRegistry();
IEditorDescriptor descriptor=
editorRegistry.getDefaultEditor(file.getName());
if (descriptor != null)
return descriptor.getId();
return "org.eclipse.ui.examples.rcp.texteditor.editors.SimpleEditor ";
//$NON-NLS-1$
}

private IEditorInput createEditorInput(File file) {
IPath location= new Path(file.getAbsolutePath());
PathEditorInput input= new PathEditorInput(location);
return input;
}
}


Thank you again,


Best regards!

Narciso Martins.
Previous Topic:[QVTO]string operations and blackboxes
Next Topic:ATL polymorphism
Goto Forum:
  


Current Time: Sun Aug 18 23:29:20 GMT 2019

Powered by FUDForum. Page generated in 0.02513 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top