List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog open
@Override public int open()
From source file:org.wso2.developerstudio.mss.artifact.ui.wizard.MSSProjectCreationWizard.java
License:Open Source License
@Override public boolean performFinish() { try {//from w w w . j a va 2 s. co m if (getModel().getSelectedOption().equals("new.MSS")) { // Creating new Eclipse project IProject project = createNewProject(); mssArtifactModel.setGeneratedCodeLocation(project.getLocation().toOSString()); mssArtifactModel.setProject(project); ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); progressMonitorDialog.create(); progressMonitorDialog.open(); progressMonitorDialog.run(false, false, new CodegenJob()); // Adding Microservices project nature to created project ProjectUtils.addNatureToProject(project, false, MSS_PROJECT_NATURE); // Sync physical location with Eclipse workspace project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } else { log.error("Unsupported Microserices project creation option"); MessageDialog errorDialog = new MessageDialog(getShell(), "Error", null, "Unsupported Microserices project creation option", MessageDialog.ERROR, new String[] { OK_BUTTON }, 0); errorDialog.open(); return false; } } catch (CoreException | InvocationTargetException | InterruptedException e) { log.error("Error while creating Microservices project for given Swagger API", e); MessageDialog errorDialog = new MessageDialog(getShell(), "Error", null, "Error while creating Microservices project for given Swagger API", MessageDialog.ERROR, new String[] { OK_BUTTON }, 0); errorDialog.open(); return false; } return true; }
From source file:org.xmind.ui.internal.sharing.SharingUtils.java
License:Open Source License
public static void run(final IRunnableWithProgress runnable, Display display) { final Throwable[] exception = new Throwable[] { null }; if (display != null && !display.isDisposed()) { display.syncExec(new Runnable() { public void run() { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null); dialog.setOpenOnRun(false); final boolean[] completed = new boolean[] { false }; Display.getCurrent().timerExec(240, new Runnable() { public void run() { if (!completed[0]) dialog.open(); }/* w w w. j a v a 2s.co m*/ }); try { dialog.run(true, false, runnable); } catch (InterruptedException e) { // ignore } catch (InvocationTargetException e) { exception[0] = e.getCause(); } catch (Throwable e) { exception[0] = e; } finally { completed[0] = true; dialog.close(); Shell shell = dialog.getShell(); if (shell != null) { shell.dispose(); } } } }); } else { try { runnable.run(new NullProgressMonitor()); } catch (InterruptedException e) { // ignore } catch (InvocationTargetException e) { exception[0] = e.getCause(); } catch (Throwable e) { exception[0] = e; } } if (exception[0] != null) { LocalNetworkSharingUI.log("Failed to disconnect from local network sharing service:", //$NON-NLS-1$ exception[0]); } }
From source file:org.yafra.rcp.commands.ConnectHandler.java
License:Apache License
@SuppressWarnings("static-access") @Override// w ww.j a va2 s . c o m public Object execute(ExecutionEvent event) throws ExecutionException { glob = GlobalSettings.getSingletonObject(); glob.setDebugmessage(" - start command connect and login"); preferredWindow = HandlerUtil.getActiveWorkbenchWindow(event); if (glob.isYafraSessionConnected()) { MessageDialog.openInformation(preferredWindow.getShell(), "Info", "You are already logged in - logoff first"); return null; } login = new LoginDialog(preferredWindow.getShell()); login.open(); if (login.getReturnCode() == (int) login.OK) { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(preferredWindow.getShell()); IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor progressMonitor) throws InterruptedException { progressMonitor.beginTask(Lloginstartmon, IProgressMonitor.UNKNOWN); try { // for the provider URL see as examples http://openejb.apache.org/clients.html // openejb in tomee http://127.0.0.1:8080/tomee/ejb // openejb standalone ejbd ejbd://localhost:4201 String ServerURL = new String(String.format("http://%s:8080/tomee/ejb", login.getServer())); Properties prop = new Properties(); prop.put(glob.getEjbcontext().INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); prop.put("java.naming.provider.url", ServerURL); glob.setEjbcontext(new InitialContext(prop)); progressMonitor.worked(1); glob.setDebugmessage(" - got context"); glob.setYafrases((YafraSessionRemote) glob.getEjbcontext().lookup("YafraSessionRemote")); glob.setDebugmessage(" - got remote session class"); glob.getYafrases().init(); progressMonitor.worked(2); glob.setDebugmessage(" - got remote init"); if (glob.getYafrases().Login(login.getUserid(), login.getPwd())) { glob.setYafraSessionConnected(true); glob.getStatusline().setMessage(null, "Ready - logged in"); glob.setDebugmessage(" - login OK"); GlobalSettings glob = GlobalSettings.getSingletonObject(); glob.setServer(login.getServer()); glob.setUser(login.getUserid()); MHIYafraUserRemote mhiuser = (MHIYafraUserRemote) glob.getEjbcontext() .lookup("MHIYafraUserRemote"); glob.setUserModel(mhiuser.selectUser(login.getUserid())); glob.setUserRoles(mhiuser.getRoles(login.getUserid())); } else { glob.setDebugmessage(" - login NOT OK - EXIT NOW"); glob.getStatusline().setMessage(null, "Ready - not logged in - ERROR with login - try again"); glob.setYafraSessionConnected(false); return; } glob.setDebugmessage(" - version got from server: " + glob.getYafrases().getVersion()); // TODO check why not returning progressMonitor.done(); } catch (Exception e) { glob.setYafraSessionConnected(false); progressMonitor.done(); Status status = new Status(IStatus.ERROR, "My Plug-in ID", 0, "EJB3 connection error", e); ErrorDialog.openError(Display.getCurrent().getActiveShell(), "EJB3 connection error", e.toString(), status); e.printStackTrace(); } }; }; try { progressDialog.open(); runnable.run(progressDialog.getProgressMonitor()); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } progressDialog.close(); try { IViewReference ref = preferredWindow.getActivePage().findViewReference("org.yafra.rcp.LoginView"); preferredWindow.getActivePage().hideView(ref); preferredWindow.getActivePage().showView("org.yafra.rcp.LoginView"); } catch (PartInitException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }
From source file:sample.handlers.SaveHandler.java
License:Open Source License
@Execute public void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution) throws InvocationTargetException, InterruptedException { final IEclipseContext pmContext = context.createChild(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.open(); dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { pmContext.set(IProgressMonitor.class.getName(), monitor); }//w ww. j a v a2 s . c o m }); pmContext.dispose(); }