use of org.talend.designer.core.IMultiPageTalendEditor in project tdi-studio-se by Talend.
the class AbstractElementPropertySectionController method init.
/**
* DOC yzhang Comment method "init".
*
* Configuration for necessay parameters from class DynamicTabbedPropertiesSection.
*/
public void init(IDynamicProperty dp) {
this.dynamicProperty = dp;
hashCurControls = dp.getHashCurControls();
elem = dp.getElement();
Object obj = dp.getPart();
if (obj instanceof IMultiPageTalendEditor) {
part = (IMultiPageTalendEditor) obj;
} else {
// throw new RuntimeException("Type IMultiPageTalendEditor is requried.");
}
section = dp.getSection();
composite = dp.getComposite();
editionControlHelper = new EditionControlHelper();
// elem.addPropertyChangeListener(this);
}
use of org.talend.designer.core.IMultiPageTalendEditor in project tdi-studio-se by Talend.
the class MavenVersionManagementProjectSettingPage method updateItemsVersion.
protected void updateItemsVersion() {
List<ItemVersionObject> JobsOpenedInEditor = new ArrayList<ItemVersionObject>();
List<ItemVersionObject> closedJobs = new ArrayList<ItemVersionObject>();
boolean hasJobOpenedInEditor = false;
StringBuilder builder = new StringBuilder();
for (ItemVersionObject object : checkedObjects) {
if (RepositoryManager.isOpenedItemInEditor(object.getRepositoryNode().getObject())) {
hasJobOpenedInEditor = true;
JobsOpenedInEditor.add(object);
//$NON-NLS-1$
builder.append(object.getRepositoryNode().getObject().getLabel() + ", ");
} else {
closedJobs.add(object);
}
}
if (builder.length() > 0) {
builder.delete(builder.length() - 2, builder.length());
}
if (hasJobOpenedInEditor) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), //$NON-NLS-1$
Messages.getString("VersionManagementDialog.WarningTitle2"), //$NON-NLS-1$
Messages.getString("VersionManagementDialog.openedInEditorMessage", builder.toString()));
IWorkbenchWindow workBench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workBench != null) {
IWorkbenchPage page = workBench.getActivePage();
IEditorReference[] editorRefs = page.getEditorReferences();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreUIService.class)) {
IDesignerCoreUIService service = (IDesignerCoreUIService) GlobalServiceRegister.getDefault().getService(IDesignerCoreUIService.class);
if (service != null) {
for (IEditorReference editorRef : editorRefs) {
IEditorPart editor = editorRef.getEditor(false);
if (editor instanceof IMultiPageTalendEditor) {
IProcess2 process = ((IMultiPageTalendEditor) editor).getProcess();
String version = null;
for (ItemVersionObject object : JobsOpenedInEditor) {
if (object.getItem().getProperty().getId().equals(process.getId())) {
version = object.getNewVersion();
break;
}
}
if (version != null) {
String jobDefaultVersion = MavenVersionUtils.getDefaultVersion(process.getProperty().getVersion());
if (version.equals(jobDefaultVersion)) {
// if default, set null to remove key from property.
version = null;
}
Command command = service.crateMavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, version);
if (process instanceof IGEFProcess) {
service.executeCommand((IGEFProcess) process, command);
}
}
}
}
}
}
}
}
final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
RepositoryWorkUnit<Object> rwu = new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
project, //$NON-NLS-1$
"Update items Maven version") {
@Override
protected void run() throws LoginException, PersistenceException {
//$NON-NLS-1$
monitor.beginTask("Update items Maven version", closedJobs.size());
for (ItemVersionObject object : closedJobs) {
final Item item = object.getItem();
Property itemProperty = item.getProperty();
MavenVersionUtils.setItemMavenVersion(itemProperty, object.getNewVersion());
monitor.subTask(itemProperty.getLabel());
FACTORY.save(project, itemProperty);
monitor.worked(1);
}
try {
FACTORY.saveProject(project);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
};
rwu.setAvoidUnloadResources(true);
rwu.executeRun();
monitor.done();
}
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
};
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(false, false, iRunnableWithProgress);
} catch (InvocationTargetException | InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.designer.core.IMultiPageTalendEditor in project tdi-studio-se by Talend.
the class OpenSQLBuilderDialogJob method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected IStatus run(IProgressMonitor monitor) {
loginProgress = new OpenSQLBuilderDialogProgress(connectionParameters, manager, composite);
Object obj = controller.getDynamicProperty().getPart();
Process p = null;
if (obj instanceof IMultiPageTalendEditor) {
p = (Process) ((IMultiPageTalendEditor) obj).getProcess();
} else {
//$NON-NLS-1$
throw new RuntimeException(Messages.getString("OpenSQLBuilderDialogJob.typeRequried"));
}
final Process process = p;
try {
loginProgress.run(monitor);
if (EDatabaseTypeName.ACCESS.getDisplayName().equals(connectionParameters.getDbType()) || connectionParameters.isStatus()) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
Shell parentShell = new Shell(composite.getShell().getDisplay());
if (elem instanceof Node) {
TextUtil.setDialogTitle(process.getName(), (String) //$NON-NLS-1$
((Node) elem).getElementParameter("LABEL").getValue(), elem.getElementName());
} else {
TextUtil.setDialogTitle(process.getName(), null, null);
}
SQLBuilderDialog dial = new SQLBuilderDialog(parentShell);
UIUtils.addSqlBuilderDialog(process.getName(), dial);
dial.setConnParameters(connectionParameters);
if (Window.OK == dial.open()) {
if (!composite.isDisposed() && !connectionParameters.isNodeReadOnly()) {
if (EParameterFieldType.DBTABLE.equals(connectionParameters.getFieldType())) {
// final String selectDBTable = connectionParameters.getSelectDBTable();
// if (selectDBTable != null) {
// Command cmd = new PropertyChangeCommand(elem, propertyName, TalendTextUtils
// .addSQLQuotes(selectDBTable));
// commandStack.execute(cmd);
// }
} else {
String sql = connectionParameters.getQuery();
sql = QueryUtil.checkAndAddQuotes(sql);
PropertyChangeCommand cmd = new PropertyChangeCommand(elem, propertyName, sql);
cmd.setUpdate(true);
commandStack.execute(cmd);
}
}
}
}
});
} else {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
String pid = SqlBuilderPlugin.PLUGIN_ID;
//$NON-NLS-1$
String mainMsg = Messages.getString("ConnectionError.Message");
if (new ErrorDialogWithDetailAreaAndContinueButton(composite.getShell(), pid, mainMsg, connectionParameters.getConnectionComment()).getCodeOfButton() == Dialog.OK) {
ConfigureConnParamDialog paramDialog = new ConfigureConnParamDialog(composite.getShell(), connectionParameters, process.getContextManager(), elem);
if (paramDialog.open() == Window.OK) {
controller.openSqlBuilderBuildIn(connectionParameters, propertyName);
}
}
}
});
}
} catch (InterruptedException ie) {
loginProgress.cleanUp();
//$NON-NLS-1$
return new Status(IStatus.CANCEL, id, IStatus.CANCEL, "Progress.OpenSqlBuilderDialog.Cancelled", null);
} catch (Exception e) {
loginProgress.cleanUp();
//$NON-NLS-1$
return new Status(IStatus.ERROR, id, IStatus.CANCEL, "Progress.OpenSqlBuilderDialog.Error", e);
}
//$NON-NLS-1$
return new Status(IStatus.OK, id, IStatus.OK, "tested ok ", null);
}
Aggregations