List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:at.spardat.xma.gui.mapper.BDInstanceSelectionDialog.java
License:Open Source License
private void browseButtonSelected() { ProgressMonitorDialog pmd = new ProgressMonitorDialog(getShell()); SelectionDialog selDialog = null;/* w w w . ja v a 2 s . c o m*/ try { selDialog = JavaUI.createTypeDialog(getShell(), pmd, SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_CLASSES, false); selDialog.setTitle("Select BusinessData"); } catch (Exception ex) { setErrorMessage(ex.toString()); } if (selDialog != null) { if (selDialog.open() == IDialogConstants.CANCEL_ID) return; Object[] types = selDialog.getResult(); if (types == null || types.length == 0) return; IType selectedType = (IType) types[0]; className_.setText(selectedType.getFullyQualifiedName()); } }
From source file:at.spardat.xma.guidesign.presentation.action.GenerateAction.java
License:Open Source License
public void run(IAction action) { if (editorPart instanceof GuidesignEditor) { final GuidesignEditor editor = (GuidesignEditor) editorPart; final XMAComponent component = editor.getComponent(); final IFile file = editor.getResourceFile(); WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) throws CoreException { editor.doSave(monitor);//from w ww . j av a2 s .c o m ProjectClassLoaderFactory.setEclipseProjectClassLoader(file.getProject()); ValidationAndGenerationExecutor.generate(file, component, monitor, true); } }; try { new ProgressMonitorDialog(editor.getSite().getShell()).run(false, false, operation); } catch (Exception exc) { GUIDesignerPlugin.INSTANCE.log(exc); if (exc instanceof InvocationTargetException) { Throwable cause = exc.getCause(); if (cause instanceof CoreException) { ErrorDialog.openError(editorPart.getEditorSite().getShell(), "Error in generation!", cause.getMessage(), ((CoreException) cause).getStatus()); } else { MessageDialog.openError(editorPart.getEditorSite().getShell(), "Unexpected exception", cause.getMessage()); } } } } }
From source file:at.spardat.xma.guidesign.presentation.GuidesignEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*from www. jav a2s . c om*/ * <!-- end-user-doc --> * @modified */ public void doSave(IProgressMonitor progressMonitor) { // Do the work within an operation because this is a long running activity that modifies the workbench. WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { // This is the method that gets invoked when the operation runs. protected void execute(IProgressMonitor monitor) throws CoreException { try { //check validty of the resource and save it to the file system. GuidesignEditor.this.checkEObjectValidty(monitor); Resource savedResource = (Resource) editingDomain.getResourceSet().getResources().get(0); ((XMIResourceImpl) savedResource).setEncoding("UTF-8"); savedResource.save(Collections.EMPTY_MAP); } catch (Exception exception) { GUIDesignerPlugin.INSTANCE.log(exception); } } }; // removing the resource listener temporally to avoid notification on our own change ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); try { // This runs the options, and shows progress. // (It appears to be a bad thing to fork this onto another thread.) new ProgressMonitorDialog(getSite().getShell()).run(false, false, operation); // Refresh the necessary state. ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone(); dirty = false; firePropertyChange(IEditorPart.PROP_DIRTY); } catch (Exception exception) { // Something went wrong that shouldn't. GUIDesignerPlugin.INSTANCE.log(exception); } finally { // add the resource listener again ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); } }
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();//w w w .j a va 2s .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 ww w .j a va 2s. 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:automaticexperiment.presentation.AutomaticexperimentEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->// www . j av a 2s .c om * <!-- end-user-doc --> * @generated */ @Override public void doSave(IProgressMonitor progressMonitor) { // Save only resources that have actually changed. // final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); // Do the work within an operation because this is a long running activity that modifies the workbench. // WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { // This is the method that gets invoked when the operation runs. // @Override public void execute(IProgressMonitor monitor) { // Save the resources to the file system. // boolean first = true; for (Resource resource : editingDomain.getResourceSet().getResources()) { if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { try { long timeStamp = resource.getTimeStamp(); resource.save(saveOptions); if (resource.getTimeStamp() != timeStamp) { savedResources.add(resource); } } catch (Exception exception) { resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); } first = false; } } } }; updateProblemIndication = false; try { // This runs the options, and shows progress. // new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); // Refresh the necessary state. // ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone(); firePropertyChange(IEditorPart.PROP_DIRTY); } catch (Exception exception) { // Something went wrong that shouldn't. // AutomaticexperienceEditPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
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 . j a va2 s. c om // 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 ww . ja v a2 s.c o 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:be.ibridge.kettle.spoon.SpoonGraph.java
License:LGPL
/** * Display the input- or outputfields for a step. * // w ww. ja v a 2s . c o m * @param stepMeta The step (it's metadata) to query * @param before set to true if you want to have the fields going INTO the step, false if you want to see all the * fields that exit the step. */ private void inputOutputFields(StepMeta stepMeta, boolean before) { spoon.refreshGraph(); SearchFieldsProgressDialog op = new SearchFieldsProgressDialog(transMeta, stepMeta, before); try { final Thread parentThread = Thread.currentThread(); final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); // Run something in the background to cancel active database queries, forecably if needed! Runnable run = new Runnable() { public void run() { // This is running in a new process: copy some KettleVariables info LocalVariables.getInstance().createKettleVariables(Thread.currentThread().getName(), parentThread.getName(), true); IProgressMonitor monitor = pmd.getProgressMonitor(); while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) { try { Thread.sleep(250); } catch (InterruptedException e) { } ; } if (monitor.isCanceled()) // Disconnect and see what happens! { try { transMeta.cancelQueries(); } catch (Exception e) { } ; } } }; // Dump the cancel looker in the background! new Thread(run).start(); pmd.run(true, true, op); } catch (InvocationTargetException e) { new ErrorDialog(shell, Messages.getString("SpoonGraph.Dialog.GettingFields.Title"), //$NON-NLS-1$ Messages.getString("SpoonGraph.Dialog.GettingFields.Message"), e); //$NON-NLS-1$ } catch (InterruptedException e) { new ErrorDialog(shell, Messages.getString("SpoonGraph.Dialog.GettingFields.Title"), //$NON-NLS-1$ Messages.getString("SpoonGraph.Dialog.GettingFields.Message"), e); //$NON-NLS-1$ } Row fields = op.getFields(); if (fields != null && fields.size() > 0) { StepFieldsDialog sfd = new StepFieldsDialog(shell, SWT.NONE, stepMeta.getName(), fields); String sn = (String) sfd.open(); if (sn != null) { StepMeta esi = transMeta.findStep(sn); if (esi != null) { editStep(esi); } } } else { MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION); mb.setMessage(Messages.getString("SpoonGraph.Dialog.CouldntFindFields.Message")); //$NON-NLS-1$ mb.setText(Messages.getString("SpoonGraph.Dialog.CouldntFindFields.Title")); //$NON-NLS-1$ mb.open(); } }
From source file:bilab.notebook.NotebookPageEditor.java
License:Open Source License
@Override public void doSaveAs() { // Show a SaveAs dialog final Shell shell = getSite().getWorkbenchWindow().getShell(); final SaveAsDialog dialog = new SaveAsDialog(shell); dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile()); dialog.open();/*from ww w.java2 s . c o m*/ final IPath path = dialog.getResult(); if (path != null) { // try to save the editor's contents under a different file name final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); try { new ProgressMonitorDialog(shell).run(false, // don't fork false, // not cancelable new WorkspaceModifyOperation() { // run this operation @Override public void execute(final IProgressMonitor monitor) { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); createOutputStream(out); file.create(new ByteArrayInputStream(out.toByteArray()), // contents true, // keep saving, even if IFile // is out of sync with the // Workspace monitor); // progress monitor } catch (final CoreException ce) { ce.printStackTrace(); } catch (final IOException ioe) { ioe.printStackTrace(); } } }); // set input to the new file setInput(new FileEditorInput(file)); getCommandStack().markSaveLocation(); } catch (final InterruptedException ie) { // should not happen, since the monitor dialog is not cancelable ie.printStackTrace(); } catch (final InvocationTargetException ite) { ite.printStackTrace(); } } // if }