use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class UpdateDocumentationAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
DocumentationUpdateWizard docWizard = new DocumentationUpdateWizard(PlatformUI.getWorkbench(), node.getObject(), getPath());
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), docWizard);
dlg.open();
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class ExtractDocumentationAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
final Item item = node.getObject().getProperty().getItem();
if (item == null) {
return;
}
String initialFileName = null;
String initialExtension = null;
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
initialFileName = documentationItem.getName();
if (documentationItem.getExtension() != null) {
initialExtension = documentationItem.getExtension();
}
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
if (!LinkUtils.validateLink(linkDocItem.getLink())) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.getString(//$NON-NLS-1$
"ExtractDocumentationAction.fileErrorTitle"), //$NON-NLS-1$
Messages.getString("ExtractDocumentationAction.fileErrorMessages"));
return;
}
initialFileName = linkDocItem.getName();
if (linkDocItem.getExtension() != null) {
initialExtension = linkDocItem.getExtension();
}
}
if (initialFileName != null) {
FileDialog fileDlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
if (initialExtension != null) {
//$NON-NLS-1$
initialFileName = initialFileName + LinkUtils.DOT + initialExtension;
//$NON-NLS-1$ //$NON-NLS-2$
fileDlg.setFilterExtensions(new String[] { "*." + initialExtension, "*.*" });
}
fileDlg.setFileName(initialFileName);
String filename = fileDlg.open();
if (filename != null) {
final File file = new File(filename);
ProgressDialog progressDialog = new ProgressDialog(Display.getCurrent().getActiveShell()) {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
documentationItem.getContent().setInnerContentToFile(file);
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
ByteArray byteArray = LinkDocumentationHelper.getLinkItemContent(linkDocItem);
if (byteArray != null) {
byteArray.setInnerContentToFile(file);
}
}
} catch (IOException ioe) {
MessageBoxExceptionHandler.process(ioe);
}
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
// Nothing to do
}
}
}
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class ExtractDocumentationAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = !selection.isEmpty() && selection.size() == 1;
RepositoryNode node = (RepositoryNode) selection.getFirstElement();
if (canWork) {
canWork = node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObject().getRepositoryObjectType() == ERepositoryObjectType.DOCUMENTATION;
}
RepositoryNode parent = null;
if (node != null) {
parent = node.getParent();
}
if (canWork && parent != null && parent instanceof BinRepositoryNode) {
canWork = false;
}
setEnabled(canWork);
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class GenericWizardService method createNodesFromComponentService.
@Override
public List<RepositoryNode> createNodesFromComponentService(RepositoryNode curParentNode) {
List<RepositoryNode> repNodes = new ArrayList<>();
Set<ComponentWizardDefinition> wizardDefinitions = internalService.getComponentService().getTopLevelComponentWizards();
for (ComponentWizardDefinition wizardDefinition : wizardDefinitions) {
String name = wizardDefinition.getName();
String displayName = wizardDefinition.getDisplayName();
//$NON-NLS-1$
String folder = "metadata/" + name;
int ordinal = 100;
ERepositoryObjectType repositoryType = internalService.createRepositoryType(name, displayName, name, folder, ordinal);
if (curParentNode != null) {
repNodes.add(internalService.createRepositoryNode(curParentNode, wizardDefinition.getDisplayName(), repositoryType, ENodeType.SYSTEM_FOLDER));
}
}
return repNodes;
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class CreateFTPConnectionAction method doRun.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.AContextualAction#doRun()
*/
@Override
protected void doRun() {
RepositoryNode dbConnectionNode = getCurrentRepositoryNode();
if (isToolbar()) {
if (dbConnectionNode != null && dbConnectionNode.getContentType() != ERepositoryObjectType.METADATA_FILE_FTP) {
dbConnectionNode = null;
}
if (dbConnectionNode == null) {
dbConnectionNode = getRepositoryNodeForDefault(ERepositoryObjectType.METADATA_FILE_FTP);
}
}
RepositoryNode metadataNode = dbConnectionNode.getParent();
if (metadataNode != null) {
// Force focus to the repositoryView and open Metadata and DbConnection nodes
IRepositoryView viewPart = getViewPart();
if (viewPart != null) {
viewPart.setFocus();
viewPart.expand(metadataNode, true);
viewPart.expand(dbConnectionNode, true);
}
}
FTPConnection connection = null;
IPath pathToSave = null;
// Define the RepositoryNode, by default Metadata/DbConnection
RepositoryNode node = dbConnectionNode;
ISelection selection = null;
// When the userSelection is an element of metadataNode, use it !
if (!isToolbar()) {
Object userSelection = ((IStructuredSelection) getSelection()).getFirstElement();
if (userSelection instanceof RepositoryNode) {
switch(((RepositoryNode) userSelection).getType()) {
case REPOSITORY_ELEMENT:
case SIMPLE_FOLDER:
case SYSTEM_FOLDER:
node = (RepositoryNode) userSelection;
break;
}
}
selection = getSelection();
}
boolean creation = false;
// Define the repositoryObject DatabaseConnection and his pathToSave
switch(node.getType()) {
case REPOSITORY_ELEMENT:
// pathToSave = null;
connection = (FTPConnection) ((ConnectionItem) node.getObject().getProperty().getItem()).getConnection();
creation = false;
break;
case SIMPLE_FOLDER:
pathToSave = RepositoryNodeUtilities.getPath(node);
connection = ConnectionFactory.eINSTANCE.createFTPConnection();
creation = true;
break;
case SYSTEM_FOLDER:
//$NON-NLS-1$
pathToSave = new Path("");
connection = ConnectionFactory.eINSTANCE.createFTPConnection();
creation = true;
break;
}
// Init the content of the Wizard
init(node);
FTPWizard ftpWizard;
if (isToolbar()) {
ftpWizard = new FTPWizard(PlatformUI.getWorkbench(), creation, node, getExistingNames());
ftpWizard.setToolBar(true);
} else {
ftpWizard = new FTPWizard(PlatformUI.getWorkbench(), creation, selection, getExistingNames());
}
// Open the Wizard
WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), ftpWizard);
wizardDialog.setPageSize(700, 550);
wizardDialog.create();
wizardDialog.open();
IRepositoryView view = getViewPart();
if (view != null) {
view.expand(dbConnectionNode, true);
}
}
Aggregations