use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class AbstractTalendEditor method doSaveAs.
@Override
public void doSaveAs() {
SaveAsDialog dialog = new SaveAsDialog(getSite().getWorkbenchWindow().getShell());
dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
dialog.open();
IPath path = dialog.getResult();
if (path == null) {
return;
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IFile file = workspace.getRoot().getFile(path);
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
@Override
public void execute(final IProgressMonitor monitor) throws CoreException {
try {
savePreviewPictures();
getProcess().saveXmlFile();
// file.refreshLocal(IResource.DEPTH_ONE, monitor);
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
};
try {
new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell()).run(false, true, op);
// setInput(new FileEditorInput((IFile) file));
getCommandStack().markSaveLocation();
setDirty(false);
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class ComponentSearcher method run.
public void run() {
final List<IRepositoryViewObject> found = new ArrayList<IRepositoryViewObject>();
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
search(monitor, componentName, found);
}
};
try {
new ProgressMonitorDialog(shell).run(true, true, op);
} catch (Exception e) {
// ignore me
}
if (found.size() > 0) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
final RepositoryReviewDialog dialog = new RepositoryReviewDialog(shell, new JobSearchResultProcessor(found), ERepositoryObjectType.PROCESS);
if (dialog.open() == RepositoryReviewDialog.OK) {
RepositoryNode result = dialog.getResult();
openEditorOperation(result);
}
}
});
} else {
MessageDialog.openInformation(shell, Messages.getString("ComponentSearcher.searchResult", componentName), //$NON-NLS-1$//$NON-NLS-2$
Messages.getString("ComponentSearcher.noJobsFound"));
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class StatLogsAndImplicitcontextTreeViewPage method save.
private void save() {
if (viewer == null) {
return;
}
final IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.getString("StatLogsAndImplicitcontextTreeViewPage.SaveProjectSettings"), //$NON-NLS-1$
(addedObjects.size() + statAddedObjects.size()) * 100);
addContext = false;
statsLogAddContextModel = false;
implicitAddContextModel = false;
Map<String, Set<String>> implicitContextVars = null;
Map<String, Set<String>> statsLogContextVars = null;
// if add some object to use project setting ,check context model
if (!addedObjects.isEmpty()) {
if (pro != null) {
Element implicitContextLoad = (Element) pro.getInitialContextLoad();
implicitContextVars = DetectContextVarsUtils.detectByPropertyType(implicitContextLoad, true);
}
}
if (!statAddedObjects.isEmpty()) {
if (pro != null) {
Element statsAndLog = (Element) pro.getStatsAndLog();
statsLogContextVars = DetectContextVarsUtils.detectByPropertyType(statsAndLog, true);
}
}
// if statslog and implicit use the same connection only show add context dialog one time
if (implicitContextVars != null && statsLogContextVars != null && !implicitContextVars.isEmpty() && !statsLogContextVars.isEmpty() && implicitContextVars.keySet().toArray()[0].equals(statsLogContextVars.keySet().toArray()[0])) {
showAddContextDialog(implicitContextVars);
if (addContext) {
statsLogAddContextModel = true;
implicitAddContextModel = true;
}
} else {
if (implicitContextVars != null && !implicitContextVars.isEmpty()) {
showAddContextDialog(implicitContextVars);
if (addContext) {
implicitAddContextModel = true;
}
}
if (statsLogContextVars != null && !statsLogContextVars.isEmpty()) {
showAddContextDialog(statsLogContextVars);
if (addContext) {
statsLogAddContextModel = true;
}
}
}
saveChangedNode(EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName(), implicitAddContextModel, implicitContextVars, monitor);
saveChangedNode(EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName(), statsLogAddContextModel, statsLogContextVars, monitor);
monitor.done();
}
};
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(true, true, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tesb-studio-se by Talend.
the class RunContainerPreferencePage method initalizeRuntime.
private boolean initalizeRuntime(String location, String host) {
boolean finished = true;
performApply();
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
try {
dialog.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
SubMonitor totalMonitor = SubMonitor.convert(monitor, 10);
totalMonitor.beginTask("Initializing Runtime server", 10);
// 1. try to stop first
totalMonitor.setTaskName("Stoping Runtime server");
new StopRuntimeProgress().run(totalMonitor);
if (RuntimeServerController.getInstance().getRuntimeProcess() != null && RuntimeServerController.getInstance().getRuntimeProcess().isAlive()) {
RuntimeServerController.getInstance().getRuntimeProcess().waitFor(20, TimeUnit.SECONDS);
}
totalMonitor.worked(2);
// 2. delete data(cannot use JMX to rebootCleanAll as a DLL delete failed)
if (monitor.isCanceled()) {
throw new InterruptedException("Initalize is canceled by user");
}
totalMonitor.setTaskName("Deleting /data folder");
try {
FileUtil.deleteFolder(location + "/data");
} catch (IOException e) {
ExceptionHandler.process(e);
throw new InterruptedException(e.getMessage());
}
if (new File(location + "/data").exists()) {
throw new InterruptedException(RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog7"));
}
totalMonitor.worked(1);
// 3. start (again)
if (monitor.isCanceled()) {
throw new InterruptedException("Initalize is canceled by user");
}
totalMonitor.setTaskName("Starting Runtime server");
new StartRuntimeProgress(false).run(totalMonitor);
totalMonitor.worked(2);
// 4. command
if (monitor.isCanceled()) {
throw new InterruptedException("Initalize is canceled by user");
}
File launcher;
String os = System.getProperty("os.name");
if (os != null && os.toLowerCase().contains("windows")) {
launcher = new File(location + "/bin/client.bat");
} else {
launcher = new File(location + "/bin/client");
}
InputStream stream = RunContainerPreferencePage.class.getResourceAsStream("/resources/commands");
File initFile = new File(location + "/scripts/initlocal.sh");
if (!initFile.exists()) {
try {
Files.copy(stream, initFile.toPath());
} catch (IOException e) {
ExceptionHandler.process(e);
throw new InterruptedException(e.getMessage());
}
}
// without username and password is ok
// fixed by KARAF-5019
String command = launcher.getAbsolutePath() + " -h " + host + " -l 1 source file:scripts/initlocal.sh";
RuntimeClientProgress clientProgress = new RuntimeClientProgress(command);
clientProgress.run(totalMonitor);
totalMonitor.done();
}
});
} catch (Throwable e) {
finished = false;
ExceptionHandler.process(e);
IStatus status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getMessage(), e);
if (e.getCause() != null) {
status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getCause().getMessage(), e.getCause());
}
RuntimeErrorDialog.openError(getShell(), RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog2"), RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog4"), status);
}
return finished;
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.
the class LoginDialog method logIn.
/**
* DOC smallet Comment method "logIn".
*
* @param project
* @throws Exception
*/
protected boolean logIn(final Project project) {
final ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
ConnectionBean connBean = loginComposite.getConnection();
final boolean needRestartForLocal = loginComposite.needRestartForLocal();
if (connBean == null || project == null || project.getLabel() == null) {
return false;
}
try {
if (!project.getEmfProject().isLocal() && factory.isLocalConnectionProvider()) {
List<IRepositoryFactory> rfList = RepositoryFactoryProvider.getAvailableRepositories();
IRepositoryFactory remoteFactory = null;
for (IRepositoryFactory rf : rfList) {
if (!rf.isLocalConnectionProvider()) {
remoteFactory = rf;
break;
}
}
if (remoteFactory != null) {
factory.setRepositoryFactoryFromProvider(remoteFactory);
factory.getRepositoryContext().setOffline(true);
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// Save last used parameters
PreferenceManipulator prefManipulator = new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
prefManipulator.setLastProject(project.getTechnicalLabel());
saveLastConnBean(connBean);
// check for Talendforge
if (PluginChecker.isExchangeSystemLoaded() && !TalendPropertiesUtil.isHideExchange()) {
IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
boolean checkTisVersion = prefStore.getBoolean(ITalendCorePrefConstants.EXCHANGE_CHECK_TIS_VERSION);
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (!checkTisVersion && brandingService.isPoweredbyTalend()) {
int count = prefStore.getInt(TalendForgeDialog.LOGINCOUNT);
if (count < 0) {
count = 1;
}
ExchangeUser exchangeUser = project.getExchangeUser();
boolean isExchangeLogon = exchangeUser.getLogin() != null && !exchangeUser.getLogin().equals("");
boolean isUserPassRight = true;
if (isExchangeLogon) {
IExchangeService service = (IExchangeService) GlobalServiceRegister.getDefault().getService(IExchangeService.class);
if (service.checkUserAndPass(exchangeUser.getUsername(), exchangeUser.getPassword()) != null) {
isUserPassRight = false;
}
}
if (!isExchangeLogon || !isUserPassRight) {
if ((count + 1) % 4 == 0) {
// if (Platform.getOS().equals(Platform.OS_LINUX)) {
// TalendForgeDialog tfDialog = new TalendForgeDialog(this.getShell(), project);
// tfDialog.open();
// } else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
String userEmail = null;
if (project.getAuthor() != null) {
userEmail = project.getAuthor().getLogin();
}
TalendForgeDialog tfDialog = new TalendForgeDialog(getShell(), userEmail);
tfDialog.setBlockOnOpen(true);
tfDialog.open();
}
});
}
prefStore.setValue(TalendForgeDialog.LOGINCOUNT, count + 1);
}
}
}
try {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
final ICoreTisService service = (ICoreTisService) GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
if (service != null) {
// if in TIS then update the bundle status according to the project type
if (!service.validProject(project, needRestartForLocal)) {
LoginComposite.isRestart = true;
return true;
}
}
// else not in TIS so ignor caus we may not have a licence so we do not know which bundles belong to
// DI, DQ or MDM
}
} catch (PersistenceException e) {
e.printStackTrace();
loginComposite.populateProjectList();
MessageDialog.openError(getShell(), getShell().getText(), e.getMessage());
return false;
}
final Shell shell = this.getShell();
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// monitorWrap = new EventLoopProgressMonitor(monitor);
try {
factory.logOnProject(project, monitor);
} catch (LoginException e) {
throw new InvocationTargetException(e);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
} catch (OperationCanceledException e) {
throw new InterruptedException(e.getLocalizedMessage());
}
monitor.done();
}
};
try {
dialog.run(true, true, runnable);
} catch (final InvocationTargetException e) {
if (PluginChecker.isSVNProviderPluginLoaded()) {
loginComposite.populateProjectList();
if (e.getTargetException() instanceof OperationCancelException) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.getString("LoginDialog.logonCanceled"), e.getTargetException().getLocalizedMessage());
}
});
} else {
MessageBoxExceptionHandler.process(e.getTargetException(), getShell());
}
} else {
loginComposite.populateTOSProjectList();
MessageBoxExceptionHandler.process(e.getTargetException(), getShell());
}
return false;
} catch (InterruptedException e) {
if (PluginChecker.isSVNProviderPluginLoaded()) {
loginComposite.populateProjectList();
} else {
loginComposite.populateTOSProjectList();
}
return false;
}
return true;
}
Aggregations