use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class ProcessVersionComposite method addPopUpMenu.
/**
* DOC Administrator Comment method "addPoppuMenu".
*/
private void addPopUpMenu() {
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager mgr) {
if (getParentWizard() == null) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action instanceof OpenExistVersionProcessAction) {
continue;
}
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
Object o = structuredSelection.getFirstElement();
if (o instanceof RepositoryNode) {
((AContextualAction) action).setAvoidUnloadResources(true);
}
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class OpenDocumentationAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
@Override
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 OpenDocumentationAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
Item item = node.getObject().getProperty().getItem();
if (item == null) {
return;
}
URL url = null;
// String extension = null;
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
// if (documentationItem.getExtension() != null) {
// extension = documentationItem.getExtension();
// }
IFile file = LinkDocumentationHelper.getTempFile(documentationItem.getName(), documentationItem.getExtension());
try {
documentationItem.getContent().setInnerContentToFile(file.getLocation().toFile());
url = file.getLocationURI().toURL();
} catch (Exception e) {
showErrorMessage();
return;
}
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
if (!LinkUtils.validateLink(linkDocItem.getLink())) {
showErrorMessage();
return;
}
// if (linkDocItem.getExtension() != null) {
// extension = linkDocItem.getExtension();
// }
String uri = linkDocItem.getLink().getURI();
if (LinkUtils.isRemoteFile(uri)) {
try {
url = new URL(uri);
} catch (MalformedURLException e) {
//
}
} else if (LinkUtils.existedFile(uri)) {
try {
url = new File(uri).toURL();
} catch (MalformedURLException e) {
//
}
}
}
openedByBrowser(item, url);
// progress(item, extension);
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class UpdateDocumentationAction method getPath.
private IPath getPath() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
IPath path;
if (node.getType() == ENodeType.SIMPLE_FOLDER || node.getType() == ENodeType.SYSTEM_FOLDER) {
path = RepositoryNodeUtilities.getPath(node);
} else {
path = RepositoryNodeUtilities.getPath(node);
}
return path;
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class UpdateDocumentationAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = !selection.isEmpty() && selection.size() == 1;
if (canWork) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
RepositoryNode node = (RepositoryNode) selection.getFirstElement();
canWork = (node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObject().getRepositoryObjectType() == ERepositoryObjectType.DOCUMENTATION && factory.isPotentiallyEditable(node.getObject()));
}
setEnabled(canWork);
}
Aggregations