use of org.talend.camel.core.model.camelProperties.RouteResourceItem in project tesb-studio-se by Talend.
the class OpenAnotherVersionResrouceWizard method openAnotherVersion.
private void openAnotherVersion(final IRepositoryNode node) /*, final boolean readonly*/
{
if (node.getObject() != null) {
Item item = node.getObject().getProperty().getItem();
IWorkbenchPage page = getActivePage();
if (item instanceof RouteResourceItem) {
RouteResourceEditorUtil.openEditor(page, node, (RouteResourceItem) item);
}
}
}
use of org.talend.camel.core.model.camelProperties.RouteResourceItem in project tesb-studio-se by Talend.
the class RouteResourceUtil method copyResources.
/**
* Copy route resource
*
* @param model
* @throws CoreException
*/
private static IFile copyResources(final IFolder folder, final ResourceDependencyModel model) {
final RouteResourceItem item = model.getItem();
EList<?> referenceResources = item.getReferenceResources();
if (referenceResources.isEmpty()) {
return null;
}
final IFile classpathFile = folder.getFile(new Path(model.getClassPathUrl()));
final ReferenceFileItem refFile = (ReferenceFileItem) referenceResources.get(0);
try (final InputStream inputStream = new ByteArrayInputStream(refFile.getContent().getInnerContent())) {
if (classpathFile.exists()) {
classpathFile.setContents(inputStream, 0, null);
} else {
if (!classpathFile.getParent().exists()) {
prepareFolder((IFolder) classpathFile.getParent());
}
classpathFile.create(inputStream, true, null);
}
} catch (CoreException | IOException e) {
ExceptionHandler.process(e);
}
return classpathFile;
}
use of org.talend.camel.core.model.camelProperties.RouteResourceItem in project tesb-studio-se by Talend.
the class OpenDefaultEditorAction method opendTextEditor.
/**
* Open or bind RouteResourceEditor
*
* @param node
*/
private void opendTextEditor(RepositoryNode node) {
Property property = (Property) node.getObject().getProperty();
RouteResourceItem item = null;
if (property != null) {
Assert.isTrue(property.getItem() instanceof RouteResourceItem);
item = (RouteResourceItem) property.getItem();
IWorkbenchPage page = getActivePage();
RouteResourceEditorUtil.openDefaultEditor(page, node, item);
}
}
use of org.talend.camel.core.model.camelProperties.RouteResourceItem in project tesb-studio-se by Talend.
the class RouteResourceEditor method saveContentsToItem.
/**
* Save the file content to EMF item.
*
* @param rrInput
*/
public static void saveContentsToItem(RouteResourceInput rrInput) {
try {
RouteResourceItem item = (RouteResourceItem) rrInput.getItem();
ReferenceFileItem refFile = (ReferenceFileItem) item.getReferenceResources().get(0);
InputStream inputstream = rrInput.getFile().getContents();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputstream));
String line = bufferedReader.readLine();
StringBuffer sb = new StringBuffer();
String lineSeparator = System.getProperty("line.separator");
while (line != null) {
sb.append(line).append(lineSeparator);
line = bufferedReader.readLine();
}
bufferedReader.close();
inputstream.close();
ByteArray content = refFile.getContent();
content.setInnerContent(sb.toString().getBytes());
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.camel.core.model.camelProperties.RouteResourceItem in project tesb-studio-se by Talend.
the class CreateRouteResourceAction method doRun.
@Override
protected void doRun() {
IRepositoryNode node = null;
NewRouteResourceWizard wizard = null;
ISelection selection = getSelection();
if (selection == null) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
node = (IRepositoryNode) obj;
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IPath path = service.getRepositoryPath(node);
if (RepositoryConstants.isSystemFolder(path.toString())) {
// Not allowed to create in system folder.
return;
}
wizard = new NewRouteResourceWizard(path);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
int open = dlg.open();
if (open == Window.OK) {
RouteResourceItem item = wizard.getItem();
IWorkbenchPage page = getActivePage();
RouteResourceEditorUtil.openEditor(page, null, item);
}
}
Aggregations