List of usage examples for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress
IRunnableWithProgress
From source file:at.rc.tacos.client.wizard.ConnectionWizard.java
License:Open Source License
@Override public boolean performFinish() { // skip and exit, if we are authenticated if (NetWrapper.getDefault().isAuthenticated()) return true; // reset the login status loginResponse = false;/*from ww w . ja v a 2 s . c o m*/ // start a thread try { getContainer().run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { monitor.beginTask( "Verbindung zum Server " + selectedServer.getDescription() + " wird hergestellt", IProgressMonitor.UNKNOWN); // connect to the new server and login NetSource.getInstance().openConnection(selectedServer); monitor.done(); } }); // if we have a connection try to login if (NetSource.getInstance().getConnection() == null) { Display.getCurrent().beep(); loginPage.setErrorMessage("Verbindung zum Server kann nicht hergestellt werden"); MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Serverfehler", "Verbindung zum Server kann nicht hergestellt werden.\n" + "Bitte versuchen sie es erneut oder whlen einen anderen Server."); // exit, we have no connection return false; } // start the monitor jobs and try to login NetWrapper.getDefault().init(); NetWrapper.getDefault().sendLoginMessage(new Login(username, password, false)); getContainer().run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InterruptedException { monitor.beginTask("Sende Anmeldeinformationen zum Server", IProgressMonitor.UNKNOWN); // sleep for some time, until we got the response from the // server while (!loginResponse) Thread.sleep(100); monitor.done(); } }); } catch (InvocationTargetException ite) { ite.printStackTrace(); return false; } catch (InterruptedException e) { return false; } // check the login status if (!NetWrapper.getDefault().isAuthenticated()) { loginPage.setErrorMessage("Anmeldung fehlgeschlagen.\n" + "Bitte berprfen Sie den angegebenen Benutzernamen und das Passwort"); Display.getCurrent().beep(); MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Anmeldung fehlgeschlagen", "Bitte berprfen Sie den angegebenen Benutzernamen und das Passwort"); return false; } else { // request data from server ModelFactory.getInstance().initalizeModel(); Display.getCurrent().beep(); MessageDialog.openInformation(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Login Erfolgreich", "Sie haben erfolgreich eine Verbindung zum Server hergestellt"); return true; } }
From source file:at.spardat.xma.gui.projectw.NewXMAJavaProjectCreationWizardPage.java
License:Open Source License
private void changeToNewProject() { IProject newProjectHandle = fMainPage.getProjectHandle(); IPath newProjectLocation = fMainPage.getLocationPath(); if (fMainPage.useDefaults()) { fCanRemoveContent = !newProjectLocation.append(fMainPage.getProjectName()).toFile().exists(); } else {/*w w w. ja v a 2 s.c o m*/ fCanRemoveContent = !newProjectLocation.toFile().exists(); } final boolean initialize = !(newProjectHandle.equals(fCurrProject) && newProjectLocation.equals(fCurrProjectLocation)); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { updateProject(initialize, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } }; try { getContainer().run(false, true, op); } catch (InvocationTargetException e) { String title = "Error"; String message = "Problems invoking the wizard"; ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // cancel pressed } }
From source file:at.spardat.xma.gui.projectw.NewXMAJavaProjectCreationWizardPage.java
License:Open Source License
private void removeProject() { if (fCurrProject == null || !fCurrProject.exists()) { return;/*from www . j av a 2 s .c o m*/ } IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { boolean noProgressMonitor = Platform.getLocation().equals(fCurrProjectLocation); if (monitor == null || noProgressMonitor) { monitor = new NullProgressMonitor(); } monitor.beginTask("remove project", 3); //$NON-NLS-1$ try { fCurrProject.delete(fCanRemoveContent, false, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } finally { monitor.done(); fCurrProject = null; fCanRemoveContent = false; } } }; try { getContainer().run(false, true, op); } catch (InvocationTargetException e) { String title = "Error"; String message = "Problems invoking the wizard"; //$NON-NLS-1$ ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // cancel pressed } }
From source file:au.gov.ga.earthsci.application.handlers.SaveHandler.java
License:Apache 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();/*from www. j a va 2 s . c o m*/ dialog.run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { pmContext.set(IProgressMonitor.class.getName(), monitor); if (contribution != null) { //Object clientObject = contribution.getObject(); //ContextInjectionFactory.invoke(clientObject, Persist.class, pmContext, null); } } }); pmContext.dispose(); }
From source file:au.gov.ga.earthsci.layer.FileLoader.java
License:Apache License
protected static Document importDataFromFile(Shell parent, final File file, final FileStore fileStore) throws Exception { // Create a DataStoreProducer which is capable of processing the file. final DataStoreProducer producer = createDataStoreProducerFromFile(file); if (producer == null) { throw new IllegalArgumentException("Unrecognized file type"); }/*from w w w.java 2 s . co m*/ final AtomicInteger progress = new AtomicInteger(0); PropertyChangeListener progressListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(AVKey.PROGRESS)) { progress.set((int) (100 * (Double) evt.getNewValue())); } } }; producer.addPropertyChangeListener(progressListener); final AtomicBoolean close = new AtomicBoolean(false); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(parent); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { try { dialog.run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Importing " + file.getName(), 100); while (true) { if (close.get()) { break; } if (monitor.isCanceled()) { producer.stopProduction(); break; } int monitorProgress = 0; int currentProgress = progress.get(); int diff = currentProgress - monitorProgress; if (diff > 0) { monitor.worked(diff); } Thread.sleep(100); } } }); } catch (InvocationTargetException e) { } catch (InterruptedException e) { producer.stopProduction(); } } }); Document doc = null; try { // Import the file into the specified FileStore. doc = createDataStoreFromFile(file, fileStore, producer); // The user clicked the ProgressMonitor's "Cancel" button. Revert any change made during production, and // discard the returned DataConfiguration reference. if (dialog.getReturnCode() == Dialog.CANCEL) { doc = null; producer.removeProductionState(); } } finally { // Remove the progress event listener from the DataStoreProducer. stop the progress timer, and signify to the // ProgressMonitor that we're done. close.set(true); producer.removePropertyChangeListener(progressListener); } return doc; }
From source file:be.ibridge.kettle.chef.Chef.java
License:LGPL
public boolean ripDB(String jobName, RepositoryDirectory repositoryDirectory, final DatabaseMeta srcDbInfo, final DatabaseMeta tgtDbInfo, String[] tablesToRip) { final String[] tables = tablesToRip; final DatabaseMeta sourceDbInfo = srcDbInfo; final DatabaseMeta targetDbInfo = tgtDbInfo; final RepositoryDirectory repdir = repositoryDirectory; final String jobname = jobName; ////from w w w .jav a 2 s . c o m // Create a new job... // jobMeta = new JobMeta(log); try { jobMeta.readDatabases(rep); } catch (KettleException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } setFilename(null); jobMeta.setName(jobname); jobMeta.setDirectory(repdir); refreshTree(); refreshGraph(); final Point location = new Point(50, 50); // The start entry... final JobEntryCopy start = jobMeta.findStart(); start.setLocation(new Point(location.x, location.y)); start.setDrawn(); // final Thread parentThread = Thread.currentThread(); // Create a dialog with a progress indicator! IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { // This is running in a new process: copy some KettleVariables info // LocalVariables.getInstance().createKettleVariables(Thread.currentThread().getName(), parentThread.getName(), true); monitor.beginTask(Messages.getString("Spoon.RipDB.Monitor.BuildingNewJob"), tables.length); //$NON-NLS-1$ monitor.worked(0); JobEntryCopy previous = start; // Loop over the table-names... for (int i = 0; i < tables.length && !monitor.isCanceled(); i++) { monitor.setTaskName( Messages.getString("Spoon.RipDB.Monitor.ProcessingTable") + tables[i] + "]..."); //$NON-NLS-1$ //$NON-NLS-2$ // // Create the new transformation... // String transname = Messages.getString("Spoon.RipDB.Monitor.Transname1") + sourceDbInfo + "].[" //$NON-NLS-1$//$NON-NLS-2$ + tables[i] + Messages.getString("Spoon.RipDB.Monitor.Transname2") + targetDbInfo + "]"; //$NON-NLS-1$ //$NON-NLS-2$ TransMeta ti = new TransMeta((String) null, transname, null); ti.setDirectory(repdir); // // Add a note // String note = Messages.getString("Spoon.RipDB.Monitor.Note1") + tables[i] //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.Monitor.Note2") + sourceDbInfo + "]" + Const.CR; //$NON-NLS-1$ //$NON-NLS-2$ note += Messages.getString("Spoon.RipDB.Monitor.Note3") + tables[i] //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.Monitor.Note4") + targetDbInfo + "]"; //$NON-NLS-1$ //$NON-NLS-2$ NotePadMeta ni = new NotePadMeta(note, 150, 10, -1, -1); ti.addNote(ni); // // Add the TableInputMeta step... // String fromstepname = Messages.getString("Spoon.RipDB.Monitor.FromStep.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$ TableInputMeta tii = new TableInputMeta(); tii.setDatabaseMeta(sourceDbInfo); tii.setSQL("SELECT * FROM " + srcDbInfo.quoteField(tables[i])); //$NON-NLS-1$ String fromstepid = StepLoader.getInstance().getStepPluginID(tii); StepMeta fromstep = new StepMeta(fromstepid, fromstepname, tii); fromstep.setLocation(150, 100); fromstep.setDraw(true); fromstep.setDescription(Messages.getString("Spoon.RipDB.Monitor.FromStep.Description") //$NON-NLS-1$ + tables[i] + Messages.getString("Spoon.RipDB.Monitor.FromStep.Description2") //$NON-NLS-1$ + sourceDbInfo + "]"); //$NON-NLS-1$ ti.addStep(fromstep); // // Add the TableOutputMeta step... // String tostepname = Messages.getString("Spoon.RipDB.Monitor.ToStep.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$ TableOutputMeta toi = new TableOutputMeta(); toi.setDatabaseMeta(targetDbInfo); toi.setTablename(tables[i]); toi.setCommitSize(100); toi.setTruncateTable(true); String tostepid = StepLoader.getInstance().getStepPluginID(toi); StepMeta tostep = new StepMeta(tostepid, tostepname, toi); tostep.setLocation(500, 100); tostep.setDraw(true); tostep.setDescription(Messages.getString("Spoon.RipDB.Monitor.ToStep.Description1") + tables[i] //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.Monitor.ToStep.Description2") + targetDbInfo + "]"); //$NON-NLS-1$ //$NON-NLS-2$ ti.addStep(tostep); // // Add a hop between the two steps... // TransHopMeta hi = new TransHopMeta(fromstep, tostep); ti.addTransHop(hi); // // Now we generate the SQL needed to run for this transformation. // // First set the limit to 1 to speed things up! String tmpSql = tii.getSQL(); tii.setSQL(tii.getSQL() + sourceDbInfo.getLimitClause(1)); String sql = ""; //$NON-NLS-1$ try { sql = ti.getSQLStatementsString(); } catch (KettleStepException kse) { throw new InvocationTargetException(kse, Messages.getString("Spoon.RipDB.Exception.ErrorGettingSQLFromTransformation") + ti //$NON-NLS-1$ + "] : " + kse.getMessage()); //$NON-NLS-1$ } // remove the limit tii.setSQL(tmpSql); // // Now, save the transformation... // try { ti.saveRep(rep); } catch (KettleException dbe) { throw new InvocationTargetException(dbe, Messages.getString("Spoon.RipDB.Exception.UnableToSaveTransformationToRepository")); //$NON-NLS-1$ } // We can now continue with the population of the job... //////////////////////////////////////////////////////////////////////// location.x = 250; if (i > 0) location.y += 100; // // We can continue defining the job. // // First the SQL, but only if needed! // If the table exists & has the correct format, nothing is done // if (sql != null && sql.length() > 0) { String jesqlname = Messages.getString("Spoon.RipDB.JobEntrySQL.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$ JobEntrySQL jesql = new JobEntrySQL(jesqlname); jesql.setDatabase(targetDbInfo); jesql.setSQL(sql); jesql.setDescription(Messages.getString("Spoon.RipDB.JobEntrySQL.Description") //$NON-NLS-1$ + targetDbInfo + "].[" + tables[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ JobEntryCopy jecsql = new JobEntryCopy(); jecsql.setEntry(jesql); jecsql.setLocation(new Point(location.x, location.y)); jecsql.setDrawn(); jobMeta.addJobEntry(jecsql); // Add the hop too... JobHopMeta jhi = new JobHopMeta(previous, jecsql); jobMeta.addJobHop(jhi); previous = jecsql; } // // Add the jobentry for the transformation too... // String jetransname = Messages.getString("Spoon.RipDB.JobEntryTrans.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$ JobEntryTrans jetrans = new JobEntryTrans(jetransname); jetrans.setTransname(ti.getName()); jetrans.setDirectory(ti.getDirectory()); JobEntryCopy jectrans = new JobEntryCopy(log, jetrans); jectrans.setDescription(Messages.getString("Spoon.RipDB.JobEntryTrans.Description1") + Const.CR //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.JobEntryTrans.Description2") + sourceDbInfo + "].[" //$NON-NLS-1$//$NON-NLS-2$ + tables[i] + "]" + Const.CR //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.JobEntryTrans.Description3") + targetDbInfo + "].[" //$NON-NLS-1$//$NON-NLS-2$ + tables[i] + "]"); //$NON-NLS-1$ jectrans.setDrawn(); location.x += 400; jectrans.setLocation(new Point(location.x, location.y)); jobMeta.addJobEntry(jectrans); // Add a hop between the last 2 job entries. JobHopMeta jhi2 = new JobHopMeta(previous, jectrans); jobMeta.addJobHop(jhi2); previous = jectrans; monitor.worked(1); } monitor.worked(100); monitor.done(); } }; try { ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); pmd.run(false, true, op); } catch (InvocationTargetException e) { new ErrorDialog(shell, Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Title"), //$NON-NLS-1$ Messages.getString("Chef.ErrorDialog.RipDB.ErrorRippingTheDatabase.Message"), e); //$NON-NLS-1$ return false; } catch (InterruptedException e) { new ErrorDialog(shell, Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Title"), //$NON-NLS-1$ Messages.getString("Chef.ErrorDialog.RipDB.ErrorRippingTheDatabase.Message"), e); //$NON-NLS-1$ return false; } finally { refreshGraph(); refreshTree(); } return true; }
From source file:be.ibridge.kettle.spoon.Spoon.java
License:LGPL
public JobMeta ripDB(final ArrayList databases, final String jobname, final RepositoryDirectory repdir, final String directory, final DatabaseMeta sourceDbInfo, final DatabaseMeta targetDbInfo, final String[] tables) { ///*from w w w . j a v a2 s . co m*/ // Create a new job... // final JobMeta jobMeta = new JobMeta(log); jobMeta.setDatabases(databases); jobMeta.setFilename(null); jobMeta.setName(jobname); if (rep != null) { jobMeta.setDirectory(repdir); } else { jobMeta.setFilename(Const.createFilename(directory, jobname, Const.STRING_JOB_DEFAULT_EXT)); } refreshTree(); refreshGraph(); final Point location = new Point(50, 50); // The start entry... final JobEntryCopy start = JobMeta.createStartEntry(); start.setLocation(new Point(location.x, location.y)); start.setDrawn(); jobMeta.addJobEntry(start); // final Thread parentThread = Thread.currentThread(); // Create a dialog with a progress indicator! IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { // This is running in a new process: copy some KettleVariables info // LocalVariables.getInstance().createKettleVariables(Thread.currentThread().getName(), // parentThread.getName(), true); monitor.beginTask(Messages.getString("Spoon.RipDB.Monitor.BuildingNewJob"), tables.length); //$NON-NLS-1$ monitor.worked(0); JobEntryCopy previous = start; // Loop over the table-names... for (int i = 0; i < tables.length && !monitor.isCanceled(); i++) { monitor.setTaskName( Messages.getString("Spoon.RipDB.Monitor.ProcessingTable") + tables[i] + "]..."); //$NON-NLS-1$ //$NON-NLS-2$ // // Create the new transformation... // String transname = Messages.getString("Spoon.RipDB.Monitor.Transname1") + sourceDbInfo + "].[" //$NON-NLS-1$//$NON-NLS-2$ + tables[i] + Messages.getString("Spoon.RipDB.Monitor.Transname2") + targetDbInfo + "]"; //$NON-NLS-1$ //$NON-NLS-2$ TransMeta transMeta = new TransMeta((String) null, transname, null); if (repdir != null) { transMeta.setDirectory(repdir); } else { transMeta.setFilename( Const.createFilename(directory, transname, Const.STRING_TRANS_DEFAULT_EXT)); } // // Add a note // String note = Messages.getString("Spoon.RipDB.Monitor.Note1") + tables[i] //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.Monitor.Note2") + sourceDbInfo + "]" + Const.CR; //$NON-NLS-1$ //$NON-NLS-2$ note += Messages.getString("Spoon.RipDB.Monitor.Note3") + tables[i] //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.Monitor.Note4") + targetDbInfo + "]"; //$NON-NLS-1$ //$NON-NLS-2$ NotePadMeta ni = new NotePadMeta(note, 150, 10, -1, -1); transMeta.addNote(ni); // // Add the TableInputMeta step... // String fromstepname = Messages.getString("Spoon.RipDB.Monitor.FromStep.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$ TableInputMeta tii = new TableInputMeta(); tii.setDatabaseMeta(sourceDbInfo); tii.setSQL("SELECT * FROM " + sourceDbInfo.quoteField(tables[i])); //$NON-NLS-1$ String fromstepid = StepLoader.getInstance().getStepPluginID(tii); StepMeta fromstep = new StepMeta(fromstepid, fromstepname, tii); fromstep.setLocation(150, 100); fromstep.setDraw(true); fromstep.setDescription(Messages.getString("Spoon.RipDB.Monitor.FromStep.Description") //$NON-NLS-1$ + tables[i] + Messages.getString("Spoon.RipDB.Monitor.FromStep.Description2") //$NON-NLS-1$ + sourceDbInfo + "]"); //$NON-NLS-1$ transMeta.addStep(fromstep); // // Add the TableOutputMeta step... // String tostepname = Messages.getString("Spoon.RipDB.Monitor.ToStep.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$ TableOutputMeta toi = new TableOutputMeta(); toi.setDatabaseMeta(targetDbInfo); toi.setTablename(tables[i]); toi.setCommitSize(100); toi.setTruncateTable(true); String tostepid = StepLoader.getInstance().getStepPluginID(toi); StepMeta tostep = new StepMeta(tostepid, tostepname, toi); tostep.setLocation(500, 100); tostep.setDraw(true); tostep.setDescription(Messages.getString("Spoon.RipDB.Monitor.ToStep.Description1") + tables[i] //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.Monitor.ToStep.Description2") + targetDbInfo + "]"); //$NON-NLS-1$ //$NON-NLS-2$ transMeta.addStep(tostep); // // Add a hop between the two steps... // TransHopMeta hi = new TransHopMeta(fromstep, tostep); transMeta.addTransHop(hi); // // Now we generate the SQL needed to run for this transformation. // // First set the limit to 1 to speed things up! String tmpSql = tii.getSQL(); tii.setSQL(tii.getSQL() + sourceDbInfo.getLimitClause(1)); String sql = ""; //$NON-NLS-1$ try { sql = transMeta.getSQLStatementsString(); } catch (KettleStepException kse) { throw new InvocationTargetException(kse, Messages.getString("Spoon.RipDB.Exception.ErrorGettingSQLFromTransformation") //$NON-NLS-1$ + transMeta + "] : " + kse.getMessage()); //$NON-NLS-1$ } // remove the limit tii.setSQL(tmpSql); // // Now, save the transformation... // boolean ok; if (rep != null) { ok = saveTransRepository(transMeta); } else { ok = saveTransFile(transMeta); } if (!ok) { throw new InvocationTargetException( new Exception(Messages .getString("Spoon.RipDB.Exception.UnableToSaveTransformationToRepository")), //$NON-NLS-1$ Messages.getString("Spoon.RipDB.Exception.UnableToSaveTransformationToRepository")); } // We can now continue with the population of the job... // ////////////////////////////////////////////////////////////////////// location.x = 250; if (i > 0) location.y += 100; // // We can continue defining the job. // // First the SQL, but only if needed! // If the table exists & has the correct format, nothing is done // if (!Const.isEmpty(sql)) { String jesqlname = Messages.getString("Spoon.RipDB.JobEntrySQL.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$ JobEntrySQL jesql = new JobEntrySQL(jesqlname); jesql.setDatabase(targetDbInfo); jesql.setSQL(sql); jesql.setDescription(Messages.getString("Spoon.RipDB.JobEntrySQL.Description") //$NON-NLS-1$ + targetDbInfo + "].[" + tables[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ JobEntryCopy jecsql = new JobEntryCopy(); jecsql.setEntry(jesql); jecsql.setLocation(new Point(location.x, location.y)); jecsql.setDrawn(); jobMeta.addJobEntry(jecsql); // Add the hop too... JobHopMeta jhi = new JobHopMeta(previous, jecsql); jobMeta.addJobHop(jhi); previous = jecsql; } // // Add the jobentry for the transformation too... // String jetransname = Messages.getString("Spoon.RipDB.JobEntryTrans.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$ JobEntryTrans jetrans = new JobEntryTrans(jetransname); jetrans.setTransname(transMeta.getName()); if (rep != null) { jetrans.setDirectory(transMeta.getDirectory()); } else { jetrans.setFileName( Const.createFilename("${" + Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY + "}", transMeta.getName(), Const.STRING_TRANS_DEFAULT_EXT)); } JobEntryCopy jectrans = new JobEntryCopy(log, jetrans); jectrans.setDescription(Messages.getString("Spoon.RipDB.JobEntryTrans.Description1") + Const.CR //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.JobEntryTrans.Description2") + sourceDbInfo + "].[" //$NON-NLS-1$//$NON-NLS-2$ + tables[i] + "]" + Const.CR //$NON-NLS-1$ + Messages.getString("Spoon.RipDB.JobEntryTrans.Description3") + targetDbInfo + "].[" //$NON-NLS-1$//$NON-NLS-2$ + tables[i] + "]"); //$NON-NLS-1$ jectrans.setDrawn(); location.x += 400; jectrans.setLocation(new Point(location.x, location.y)); jobMeta.addJobEntry(jectrans); // Add a hop between the last 2 job entries. JobHopMeta jhi2 = new JobHopMeta(previous, jectrans); jobMeta.addJobHop(jhi2); previous = jectrans; monitor.worked(1); } monitor.worked(100); monitor.done(); } }; try { ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); pmd.run(false, true, op); } catch (InvocationTargetException e) { new ErrorDialog(shell, Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Title"), //$NON-NLS-1$ Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Message"), e); //$NON-NLS-1$ return null; } catch (InterruptedException e) { new ErrorDialog(shell, Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Title"), //$NON-NLS-1$ Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Message"), e); //$NON-NLS-1$ return null; } finally { refreshGraph(); refreshTree(); } return jobMeta; }
From source file:bndtools.editor.components.ComponentNameProposalProvider.java
License:Open Source License
@Override protected List<IContentProposal> doGenerateProposals(String contents, int position) { final String prefix = contents.substring(0, position); IJavaProject javaProject = searchContext.getJavaProject(); final List<IContentProposal> result = new ArrayList<IContentProposal>(100); // Resource matches IProject project = javaProject.getProject(); try {/*from ww w .java 2s . c o m*/ project.accept(new IResourceProxyVisitor() { public boolean visit(IResourceProxy proxy) throws CoreException { if (proxy.getType() == IResource.FILE) { if (proxy.getName().toLowerCase().startsWith(prefix) && proxy.getName().toLowerCase().endsWith(XML_SUFFIX)) { result.add(new ResourceProposal(proxy.requestResource())); } return false; } // Recurse into everything else return true; } }, 0); } catch (CoreException e) { Plugin.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error searching for resources.", e)); } // Class matches final IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }); final TypeNameRequestor requestor = new TypeNameRequestor() { @Override public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { if (!Flags.isAbstract(modifiers) && (Flags.isPublic(modifiers) || Flags.isProtected(modifiers))) { result.add(new JavaContentProposal(new String(packageName), new String(simpleTypeName), false)); } }; }; final IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { new SearchEngine().searchAllTypeNames(null, 0, prefix.toCharArray(), SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.CLASS, scope, requestor, IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, monitor); } catch (JavaModelException e) { throw new InvocationTargetException(e); } } }; IRunnableContext runContext = searchContext.getRunContext(); try { if (runContext != null) { runContext.run(false, false, runnable); } else { runnable.run(new NullProgressMonitor()); } } catch (InvocationTargetException e) { Plugin.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error searching for classes.", e.getTargetException())); } catch (InterruptedException e) { // Reset the interruption status and continue Thread.currentThread().interrupt(); } return result; }
From source file:bndtools.editor.components.MethodProposalProvider.java
License:Open Source License
@Override public List<IContentProposal> doGenerateProposals(String contents, int position) { final String prefix = contents.substring(0, position); final List<IContentProposal> result = new ArrayList<IContentProposal>(); try {/*from w w w.j a v a 2 s .c o m*/ IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { SubMonitor progress = SubMonitor.convert(monitor, 10); try { IJavaProject project = searchContext.getJavaProject(); String targetTypeName = searchContext.getTargetTypeName(); IType targetType = project.findType(targetTypeName, progress.newChild(1)); if (targetType == null) return; ITypeHierarchy hierarchy = targetType.newSupertypeHierarchy(progress.newChild(5)); IType[] classes = hierarchy.getAllClasses(); progress.setWorkRemaining(classes.length); for (IType clazz : classes) { IMethod[] methods = clazz.getMethods(); for (IMethod method : methods) { if (method.getElementName().toLowerCase().startsWith(prefix)) { // String[] parameterTypes = method.getParameterTypes(); // TODO check parameter type result.add(new MethodContentProposal(method)); } } progress.worked(1); } } catch (JavaModelException e) { throw new InvocationTargetException(e); } } }; IRunnableContext runContext = searchContext.getRunContext(); if (runContext != null) { runContext.run(false, false, runnable); } else { runnable.run(new NullProgressMonitor()); } return result; } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return Collections.emptyList(); }
From source file:bndtools.editor.components.SvcInterfaceProposalProvider.java
License:Open Source License
@Override protected List<IContentProposal> doGenerateProposals(String contents, int position) { final String prefix = contents.substring(0, position); final IJavaSearchScope scope = SearchEngine .createJavaSearchScope(new IJavaElement[] { searchContext.getJavaProject() }); final ArrayList<IContentProposal> result = new ArrayList<IContentProposal>(100); final TypeNameRequestor typeNameRequestor = new TypeNameRequestor() { @Override/*from w ww .j a va 2 s . c om*/ public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { boolean isInterface = Flags.isInterface(modifiers); result.add( new JavaContentProposal(new String(packageName), new String(simpleTypeName), isInterface)); } }; IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { new SearchEngine().searchAllTypeNames(null, 0, prefix.toCharArray(), SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.CLASS_AND_INTERFACE, scope, typeNameRequestor, IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, monitor); } catch (JavaModelException e) { throw new InvocationTargetException(e); } } }; try { if (searchContext.getRunContext() == null) { runnable.run(new NullProgressMonitor()); } else { searchContext.getRunContext().run(false, false, runnable); } } catch (InvocationTargetException e) { Plugin.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error searching for Java types.", e.getTargetException())); return Collections.emptyList(); } catch (InterruptedException e) { // Reset interrupted status and return empty Thread.currentThread().interrupt(); return Collections.emptyList(); } return result; }