use of org.talend.repository.model.IRepositoryService in project tesb-studio-se by Talend.
the class RouteResourceEditorUtil method isReadOnly.
public static boolean isReadOnly(IRepositoryNode node) {
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
/*
* if user is readonly , then set enable as false
*/
if (repFactory.isUserReadOnlyOnCurrentProject()) {
return true;
}
// if it's not in current project, then it's disable
if (!ProjectManager.getInstance().isInCurrentMainProject(node)) {
return true;
}
// if it's locked by others, then it's disable
IRepositoryViewObject object = node.getObject();
if (object == null) {
return false;
}
Property property = object.getProperty();
if (property == null) {
return false;
}
Item item = property.getItem();
if (item == null) {
return false;
}
ERepositoryStatus status = repFactory.getStatus(item);
if (ERepositoryStatus.LOCK_BY_OTHER.equals(status) || ERepositoryStatus.DELETED.equals(status)) {
return true;
}
if (!isLatestVersion(property)) {
return true;
}
return false;
}
use of org.talend.repository.model.IRepositoryService in project tesb-studio-se by Talend.
the class OpenDefaultEditorAction method init.
// private ISelection getSelectedObject() {
// if (params == null) {
// return getSelection();
// }
// else {
// RepositoryNode repositoryNode = RepositoryNodeUtilities
// .getRepositoryNode(params.getProperty("nodeId"), false); //$NON-NLS-1$
// IRepositoryView viewPart = getViewPart();
// if (repositoryNode != null && viewPart != null) {
// RepositoryNodeUtilities.expandParentNode(viewPart,
// repositoryNode);
// return new StructuredSelection(repositoryNode);
// }
// 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;
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();
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (!factory.isUserReadOnlyOnCurrentProject() && repFactory.isPotentiallyEditable(node.getObject())) {
//$NON-NLS-1$
this.setText(Messages.getString("OpenDefaultEditorAction_title"));
} else {
//$NON-NLS-1$
this.setText(Messages.getString("OpenDefaultEditorAction_title_read"));
}
}
break;
default:
canWork = false;
}
RepositoryNode parent = node.getParent();
if (canWork && parent != null && parent instanceof BinRepositoryNode) {
canWork = false;
}
// job version is the latest verison or not.
if (canWork) {
canWork = isLastVersion(node);
}
}
setEnabled(canWork);
//$NON-NLS-1$
this.setToolTipText(Messages.getString("OpenDefaultEditorAction_tooltip"));
this.setImageDescriptor(RouteResourceActivator.createImageDesc(//$NON-NLS-1$
"icons/edit-resource.png"));
}
use of org.talend.repository.model.IRepositoryService in project tdi-studio-se by Talend.
the class UpgradeAttributestFilterRow method execute.
/*
* (non-Javadoc)
*
* @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
* ProcessItem)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() == ECodeLanguage.PERL || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
} else {
//$NON-NLS-1$
String functionName = "FUNCTION";
//$NON-NLS-1$
String operatorName = "OPERATOR";
String[][] replaceFuntions = new String[][] { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
{ "S_VALUE_OF", "" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
{ "N_VALUE_OF_FLOAT", "" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
{ "N_VALUE_OF_INTEGER", "" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
{ "ABS_VALUE_FLOAT", "Math.abs($source) $operator $target" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "ABS_VALUE_INTEGER", "Math.abs($source) $operator $target" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "LC", "$source == null? false : $source.toLowerCase().compareTo($target) $operator 0" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "UC", "$source == null? false : $source.toUpperCase().compareTo($target) $operator 0" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "LCFIRST", "$source == null? false : $source.toLowerCase().charAt(0).compareTo($target) $operator 0" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "UCFIRST", "$source == null? false : $source.toUpperCase().charAt(0).compareTo($target) $operator 0" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "LENGTH", "$source == null? false : $source.length() $operator $target" } };
String[][] replaceOperator = new String[][] { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "EQ", "==" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "NE", "!=" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "GT", ">" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "LT", "<" }, { "GE", ">=" }, { "LE", "<=" }, { "MATCH", "==" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "NMATCH", "!=" } };
boolean isModified = false;
NodeType tFilterRow = null;
for (Object oNodeType : processType.getNode()) {
NodeType nodeType = (NodeType) oNodeType;
if (nodeType.getComponentName().equals("tFilterRow")) {
//$NON-NLS-1$
tFilterRow = nodeType;
break;
}
}
if (tFilterRow != null) {
EList elementParameter = tFilterRow.getElementParameter();
for (Object object : elementParameter) {
ElementParameterTypeImpl parameter = (ElementParameterTypeImpl) object;
if (parameter.getName().equals("CONDITIONS")) {
//$NON-NLS-1$
EList elementValue = parameter.getElementValue();
ElementValueTypeImpl lastFunctionForMatch = null;
for (Object object2 : elementValue) {
ElementValueTypeImpl tableElement = (ElementValueTypeImpl) object2;
if (tableElement.getElementRef().equals(functionName)) {
for (String[] element : replaceFuntions) {
if (element[0].equals(tableElement.getValue())) {
tableElement.setValue(element[1]);
lastFunctionForMatch = tableElement;
isModified = true;
}
}
} else if (tableElement.getElementRef().equals(operatorName)) {
for (String[] element : replaceOperator) {
// list"
if ("MATCH".equals(tableElement.getValue()) || "NMATCH".equals(tableElement.getValue())) {
//$NON-NLS-1$ //$NON-NLS-2$
if (lastFunctionForMatch != null) {
lastFunctionForMatch.setValue(//$NON-NLS-1$
"$source == null? false : $source.matches($target) $operator true");
isModified = true;
}
}
if (element[0].equals(tableElement.getValue())) {
tableElement.setValue(element[1]);
isModified = true;
}
}
}
}
} else if (parameter.getName().equals("LOGICAL_OP")) {
//$NON-NLS-1$
if (parameter.getValue().equals("AND")) {
//$NON-NLS-1$
//$NON-NLS-1$
parameter.setValue("&&");
isModified = true;
} else if (parameter.getValue().equals("OR")) {
//$NON-NLS-1$
//$NON-NLS-1$
parameter.setValue("||");
isModified = true;
}
}
}
}
if (isModified) {
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
try {
factory.save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
}
use of org.talend.repository.model.IRepositoryService 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);
}
}
use of org.talend.repository.model.IRepositoryService in project tesb-studio-se by Talend.
the class CreateCamelProcess method doRun.
@Override
protected void doRun() {
final CamelNewProcessWizard processWizard;
if (isToolbar()) {
processWizard = new CamelNewProcessWizard(null);
} else {
ISelection selection = getSelection();
if (selection == null) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IPath path = service.getRepositoryPath((IRepositoryNode) obj);
if (RepositoryConstants.isSystemFolder(path.toString())) {
// Not allowed to create in system folder.
return;
}
processWizard = new CamelNewProcessWizard(path);
}
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
if (dlg.open() == Window.OK) {
if (processWizard.getProcess() == null) {
return;
}
try {
openEditor(processWizard.getProcess());
} catch (PartInitException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
MessageBoxExceptionHandler.process(e);
}
}
}
Aggregations