@Override protected void doRun() { RepositoryNode routineNode = getCurrentRepositoryNode(); if (isToolbar()) { if (routineNode != null && routineNode.getContentType() != ERepositoryObjectType.PIG_UDF) { routineNode = null; } if (routineNode == null) { routineNode = getRepositoryNodeForDefault(ERepositoryObjectType.PIG_UDF); } } RepositoryNode node = null; IPath path = null; if (!isToolbar()) { ISelection selection = getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); node = (RepositoryNode) obj; path = RepositoryNodeUtilities.getPath(node); } NewPigudfWizard routineWizard = new NewPigudfWizard(path); WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), routineWizard); if (dlg.open() == Window.OK) { try { openRoutineEditor(routineWizard.getPigudf(), false); } catch (PartInitException e) { MessageBoxExceptionHandler.process(e); } catch (SystemException e) { MessageBoxExceptionHandler.process(e); } } }
/* * (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) { super.init(viewer, selection); boolean canWork = !selection.isEmpty() && selection.size() == 1; IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance(); if (factory.isUserReadOnlyOnCurrentProject()) { canWork = false; } RepositoryNode node = (RepositoryNode) selection.getFirstElement(); if (canWork) { if (node.getObjectType() != ERepositoryObjectType.ROUTINES || !ProjectManager.getInstance().isInCurrentMainProject(node) || !isLastVersion(node)) { canWork = false; } else { Item item = node.getObject().getProperty().getItem(); if (item instanceof RoutineItem) { canWork = !((RoutineItem) item).isBuiltIn(); } } } if (canWork) { canWork = (factory.getStatus(node.getObject()) != ERepositoryStatus.DELETED); } setEnabled(canWork); }
/** * @param workbench * @param repositoryNode * @param sapConnectioItem * @param sapFunctionUnit * @param metadataTable * @param existingNames * @param creation */ public SapTableWizard( IWorkbench workbench, RepositoryNode repositoryNode, SAPConnectionItem sapConnectioItem, SAPFunctionUnit sapFunctionUnit, MetadataTable metadataTable, String[] existingNames, boolean creation) { super(workbench, creation); this.connectionItem = sapConnectioItem; this.functionUnit = sapFunctionUnit; this.existingNames = existingNames; this.metadataTable = metadataTable; this.creation = creation; setRepositoryObject(repositoryNode.getObject()); pathToSave = RepositoryNodeUtilities.getPath(repositoryNode); this.connectionProperty = repositoryNode.getObject().getProperty(); this.connectionItem.setProperty(connectionProperty); setNeedsProgressMonitor(true); isRepositoryObjectEditable(); initLockStrategy(); ConnectionContextHelper.checkContextMode(connectionItem); }
/* * (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; if (canWork) { Object o = selection.getFirstElement(); RepositoryNode node = (RepositoryNode) o; if (CamelEditorUtil.hasEditorOpened(node)) { canWork = false; } else { switch (node.getType()) { case REPOSITORY_ELEMENT: if (node.getObjectType() != CamelRepositoryNodeType.repositoryRoutesType) { canWork = false; } break; default: canWork = false; } } if (canWork && node.getObject() != null && ProxyRepositoryFactory.getInstance().getStatus(node.getObject()) == ERepositoryStatus.LOCK_BY_USER) { canWork = false; } } setEnabled(canWork); }
/* * (non-Javadoc) * * @see org.talend.commons.ui.swt.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; IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance(); if (factory.isUserReadOnlyOnCurrentProject()) { canWork = false; } if (canWork) { Object o = selection.getFirstElement(); RepositoryNode node = (RepositoryNode) o; switch (node.getType()) { case SIMPLE_FOLDER: case SYSTEM_FOLDER: ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE); if (nodeType != ERepositoryObjectType.PIG_UDF) { canWork = false; } if (node.getObject() != null && node.getObject().isDeleted()) { canWork = false; } break; default: canWork = false; } if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) { canWork = false; } } setEnabled(canWork); }
/** Adds a submenu to the given menu with the name "New Component". */ @Override public void fillContextMenu(IMenuManager menu) { // MOD mzhao user readonly role on svn repository mode. if (!isShowMenu()) { return; } // ADD msjian TDQ-10444: fix get error when click on the exchange node if (isExchangeNode()) { return; } // TDQ-10444~ Object obj = ((TreeSelection) this.getContext().getSelection()).getFirstElement(); if (obj instanceof RepositoryNode) { RepositoryNode node = (RepositoryNode) obj; // RepositoryNode parent = node.getParent(); // if (!(parent instanceof ReportSubFolderRepNode)) { if (shouldShowDeleteMenu(node)) { // menu.add(new DeleteObjectsAction()); menu.add(new DQDeleteAction()); if (shouldShowRenameFolderMenu(node)) { Object type = node.getProperties(EProperties.CONTENT_TYPE); if (ERepositoryObjectType.TDQ_JRAXML_ELEMENT.equals(type)) { menu.add(new RenameJrxmlFolderAction(node)); } else { menu.add(new RenameTdqFolderAction(node)); } } } // } } }
/* * (non-Javadoc) * * @see org.talend.repository.tester.AbstractNodeTester#testProperty(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) */ @Override protected Boolean testProperty( Object receiver, String property, Object[] args, Object expectedValue) { if (receiver instanceof RepositoryNode) { RepositoryNode repositoryNode = (RepositoryNode) receiver; final ERepositoryObjectType propertyType = ERepositoryObjectType.METADATA_SAPCONNECTIONS; if (propertyType != null) { if (repositoryNode.getType() == ENodeType.STABLE_SYSTEM_FOLDER) { // stable folder(Queries,Table schemas, View schemas, Synonym schemas, Columns) Boolean parentTest = testProperty(repositoryNode.getParent(), property, args, expectedValue); if (parentTest != null) { // only do for the checked parent. return parentTest; } } boolean currentType = isTypeNode(repositoryNode, propertyType); /* * check the implication, such as query, schema, column,[CDC] etc */ boolean schemaTest = checkImplicatedTeser( schemaTester, repositoryNode, ERepositoryObjectType.METADATA_SAP_FUNCTION, propertyType); return currentType || schemaTest; } } return null; }
private boolean isRecycleBin(Object element) { if (element instanceof RepositoryNode) { RepositoryNode node = (RepositoryNode) element; return node.isBin(); } return false; }
@SuppressWarnings("unchecked") public void init() { RepositoryNode[] selectedNodes = (RepositoryNode[]) ((IStructuredSelection) selectionProvider.getSelection()) .toList() .toArray(new RepositoryNode[] {}); if (selectedNodes.length == 0) { this.setEnabled(false); return; } int i = 0; for (RepositoryNode node : selectedNodes) { if (node.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.FOLDER || node.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.QUERY || node.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.QUERIESCONNECTION) { i++; } } if (i > 0) { this.setEnabled(false); } else { this.setEnabled(true); } }
public void init(TreeViewer viewer, IStructuredSelection selection) { boolean canWork = selection.size() == 1; if (canWork) { Object o = ((IStructuredSelection) selection).getFirstElement(); if (o instanceof RepositoryNode) { RepositoryNode node = (RepositoryNode) o; switch (node.getType()) { case REPOSITORY_ELEMENT: if (node.getObjectType() == JSONRepositoryNodeType.JSON) { canWork = true; } else { canWork = false; } break; default: canWork = false; break; } if (canWork) { canWork = (node.getObject().getRepositoryStatus() != ERepositoryStatus.DELETED); } if (canWork) { canWork = isLastVersion(node); } } } setEnabled(canWork); }
/* * (non-Javadoc) * * @see org.eclipse.jface.action.Action#run() */ protected void doRun() { ISelection selection = getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); RepositoryNode node = (RepositoryNode) obj; CamelProcessItem processItem = (CamelProcessItem) node.getObject().getProperty().getItem(); IWorkbenchPage page = getActivePage(); try { CamelProcessEditorInput fileEditorInput = new CamelProcessEditorInput(processItem, true, null, true); checkUnLoadedNodeForProcess(fileEditorInput); IEditorPart editorPart = page.findEditor(fileEditorInput); if (editorPart == null) { fileEditorInput.setRepositoryNode(node); page.openEditor(fileEditorInput, CamelMultiPageTalendEditor.ID, true); } else { page.activate(editorPart); } } catch (PartInitException e) { MessageBoxExceptionHandler.process(e); } catch (PersistenceException e) { MessageBoxExceptionHandler.process(e); } }
@Override protected void doRun() { ISelection selection = getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); RepositoryNode node = (RepositoryNode) obj; IPath path = RepositoryNodeUtilities.getPath(node); String originalName = node.getObject().getLabel(); RepositoryObject repositoryObj = new RepositoryObject(node.getObject().getProperty()); repositoryObj.setRepositoryNode(node.getObject().getRepositoryNode()); OpenExistVersionProcessWizard wizard = new OpenExistVersionProcessWizard(repositoryObj); PropertyManagerWizardDialog dialog = new PropertyManagerWizardDialog(Display.getCurrent().getActiveShell(), wizard); dialog.setPageSize(300, 250); dialog.setTitle(Messages.getString("OpenExistVersionProcess.open.dialog")); // $NON-NLS-1$ if (dialog.open() == Dialog.OK) { refresh(node); // refresh the corresponding editor's name IEditorPart part = getCorrespondingEditor(node); if (part != null && part instanceof IUIRefresher) { ((IUIRefresher) part).refreshName(); } else { processRoutineRenameOperation(originalName, node, path); } } }
/** * this is called when the model has changed and we need to reset the top level node for the next * refresh. At the next refresh the model will be constructed again. */ protected void resetTopLevelNode(RepositoryNode aTopLevelNode) { if (aTopLevelNode != null) { // reset top level node aTopLevelNode.setInitialized(false); aTopLevelNode.getChildren().clear(); } // initRepositoryNode(topLevelNode2); }
public void internalExpand(Object element) { if (element instanceof RepositoryNode) { RepositoryNode repositoryNode = (RepositoryNode) element; if (idIsValid(repositoryNode)) { expanded.put(repositoryNode.getId(), true); } } }
public void internalCollapse(Object element) { if (element instanceof RepositoryNode) { RepositoryNode repositoryNode = (RepositoryNode) element; if (idIsValid(repositoryNode)) { expanded.put(repositoryNode.getId(), false); } emptyExpandedChildren(repositoryNode); } }
/** * DOC sgandon Comment method "getRepositoryNodeChildren". * * @param element * @param repositoryNode * @return */ protected Object[] getRepositoryNodeChildren(RepositoryNode repositoryNode) { if (!repositoryNode.isInitialized()) { if (repositoryNode.getParent() instanceof ProjectRepositoryNode) { // initialize repository from main project initializeChildren(repositoryNode); } // else sub sub node so no need to initialize repositoryNode.setInitialized(true); } // else already initialised return repositoryNode.getChildren().toArray(); }
private void openAnotherVersion(final RepositoryNode 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); } } }
/* * (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); }
@Override public Image getImage(Object element) { if (isRecycleBin(element)) { RepositoryNode recyclebinNode = (RepositoryNode) element; if (recyclebinNode.getChildren().isEmpty()) { return ImageProvider.getImage(ECoreImage.RECYCLE_BIN_EMPTY_ICON); } else { return ImageProvider.getImage(ECoreImage.RECYCLE_BIN_FULL_ICON); } } return null; // if others, ignore }
public boolean getExpanded(Item item) { RepositoryNode repositoryNode = getRepositoryNode(item); if (repositoryNode != null && repositoryNode.getId() != null) { Boolean result = expanded.get(repositoryNode.getId()); if (result != null) { if (item instanceof TreeItem) { TreeItem treeItem = (TreeItem) item; treeItem.setExpanded(result); } } } return true; }
private boolean doOldUpdates(IStructuredSelection selection) { Object firstElement = selection.getFirstElement(); if (firstElement == null || !(firstElement instanceof RepositoryNode)) { return false; } RepositoryNode node = (RepositoryNode) firstElement; if (node.getObject() instanceof ISubRepositoryObject) { ISubRepositoryObject subObject = (ISubRepositoryObject) node.getObject(); if (subObject != null) { // schema AbstractMetadataObject metadataObject = subObject.getAbstractMetadataObject(); if (metadataObject instanceof MetadataTable) { return RepositoryUpdateManager.updateSchema( (MetadataTable) metadataObject, node, false, false); } else // query if (metadataObject instanceof Query) { return RepositoryUpdateManager.updateQuery((Query) metadataObject, node, false, false); } else // sap function if (metadataObject instanceof SAPFunctionUnit) { return RepositoryUpdateManager.updateSAPFunction( (SAPFunctionUnit) metadataObject, false, false); } } } else { IRepositoryViewObject object = node.getObject(); if (object != null) { Item item = object.getProperty().getItem(); if (item != null) { // context if (item instanceof ContextItem) { return RepositoryUpdateManager.updateContext((ContextItem) item, false, false); } else // connection if (item instanceof ConnectionItem) { Connection connection = ((ConnectionItem) item).getConnection(); if (connection instanceof DatabaseConnection) { return RepositoryUpdateManager.updateDBConnection( (ConnectionItem) item, false, false); } else { return RepositoryUpdateManager.updateFileConnection( (ConnectionItem) item, false, false); } } } } } return false; }
private boolean isSystemIndicator(RepositoryNode node) { switch (node.getType()) { case TDQ_REPOSITORY_ELEMENT: case REPOSITORY_ELEMENT: if (node.getObject() != null) { Item item = node.getObject().getProperty().getItem(); IFolder folder = WorkbenchUtils.getFolder(node); return item instanceof TDQIndicatorDefinitionItem && ResourceService.isSubFolder(ResourceManager.getSystemIndicatorFolder(), folder); } default: } return false; }
public SaveAsSQLAction(RepositoryNode repositoryNodeInput, ConnectionParameters query) { this.query = query.getQueryObject(); this.repositoryNode = repositoryNodeInput; SqlBuilderRepositoryObject o = (SqlBuilderRepositoryObject) repositoryNode.getObject(); boolean isBuildin = o.isBuildIn() || query.isNodeReadOnly(); setEnabled(!isBuildin); }
private boolean shouldShowDeleteMenu(RepositoryNode node) { return (!isSystemFolder(node) && !isVirturalNode(node) && !isSystemIndicator(node) && !node.isBin()) || (node instanceof ReportFileRepNode); }
@Override protected IEditorPart getCorrespondingEditor(RepositoryNode node) { IEditorReference[] eidtors = getActivePage().getEditorReferences(); for (IEditorReference eidtor : eidtors) { try { IEditorInput input = eidtor.getEditorInput(); if (!(input instanceof JobEditorInput)) { continue; } JobEditorInput repositoryInput = (JobEditorInput) input; checkUnLoadedNodeForProcess(repositoryInput); if (repositoryInput.getItem().equals(node.getObject().getProperty().getItem())) { IPath path = repositoryInput.getFile().getLocation(); return eidtor.getEditor(false); } } catch (PartInitException e) { continue; } } return null; }
/* * (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; IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance(); if (factory.isUserReadOnlyOnCurrentProject()) { canWork = false; } if (canWork) { Object o = selection.getFirstElement(); RepositoryNode node = (RepositoryNode) o; switch (node.getType()) { case REPOSITORY_ELEMENT: if (node.getObjectType() != CamelRepositoryNodeType.repositoryRouteResourceType) { canWork = false; } else { IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService(); IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory(); if (repFactory.isPotentiallyEditable(node.getObject())) { this.setText(""); // $NON-NLS-1$ } else { this.setText(""); // $NON-NLS-1$ } } break; default: canWork = false; } RepositoryNode parent = node.getParent(); if (canWork && parent != null && parent instanceof BinRepositoryNode) { canWork = false; } if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) { canWork = false; } // If the editProcess action canwork is true, then detect that the // job version is the latest verison or not. if (canWork) { canWork = isLastVersion(node); } } setEnabled(canWork); this.setText("Open another version"); this.setToolTipText("Open another version"); this.setImageDescriptor( RouteResourceActivator.createImageDesc("icons/open-another-version.png")); }
private void emptyExpandedChildren(RepositoryNode repositoryNode) { for (IRepositoryNode children : repositoryNode.getChildren()) { if (idIsValid(children)) { expanded.remove(children.getId()); } emptyExpandedChildren((RepositoryNode) children); } }
/* * (non-Javadoc) * * @see org.talend.repository.ui.actions.AContextualView#getClassForDoubleClick() */ @Override public Class getClassForDoubleClick() { RepositoryNode node = null; try { node = getCurrentRepositoryNode(); } catch (Exception e) { // } if (node != null && node.getObject() != null) { Item item = node.getObject().getProperty().getItem(); if (item != null && item instanceof LinkDocumentationItem) { return LinkDocumentationItem.class; } } // default, when init the double click action return DocumentationItem.class; }
@Override public boolean hasChildren(Object element) { Boolean boolean1 = factory.hasChildren(element); if (boolean1 != null) { return boolean1; } else { if (element instanceof RepositoryNode) { final RepositoryNode repositoryNode = (RepositoryNode) element; if (repositoryNode.isInitialized()) { return repositoryNode.hasChildren(); } else { return getChildren(element).length > 0; } } return true; } }
@Override public boolean valid( Item item, ERepositoryObjectType type, RepositoryNode seletetedNode, IComponent component, String repositoryType) { if (!(item instanceof MDMConnectionItem)) { return false; } // for mdm MdmConceptType mdmType = null; if (item instanceof MDMConnectionItem) { MDMConnectionItem mdmItem = (MDMConnectionItem) item; if (seletetedNode != null && seletetedNode.getObject() instanceof MetadataTableRepositoryObject) { MetadataTableRepositoryObject object = (MetadataTableRepositoryObject) seletetedNode.getObject(); if (mdmItem.getConnection() instanceof MDMConnection) { MDMConnection connection = (MDMConnection) mdmItem.getConnection(); for (Object obj : connection.getSchemas()) { if (obj instanceof Concept && object.getLabel().equals(((Concept) obj).getLabel())) { mdmType = ((Concept) obj).getConceptType(); } } } } } String componentProductname = component.getRepositoryType(); if (componentProductname != null && repositoryType.endsWith(componentProductname) && validSub(item, type, seletetedNode, component, repositoryType)) { if (MdmConceptType.INPUT.equals(mdmType) && component.getName().endsWith(RepositoryComponentManager.INPUT)) { return true; } else if (MdmConceptType.OUTPUT.equals(mdmType) && component.getName().endsWith(RepositoryComponentManager.OUTPUT)) { return true; } else if (MdmConceptType.RECEIVE.equals(mdmType) && component.getName().endsWith(RECEIVE)) { return true; } } return false; }