use of org.talend.commons.exception.BusinessException in project tdq-studio-se by Talend.
the class Application method start.
/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
*/
@Override
public Object start(IApplicationContext context) {
Display display = PlatformUI.createDisplay();
Shell shell = new Shell(display, SWT.ON_TOP);
// TDQ-12221: do check before use to make sure can popup the "Connect to TalendForge"
checkBrowserSupport();
try {
boolean accept = openLicenseAndRegister(shell);
if (!accept) {
return IApplication.EXIT_OK;
}
} catch (BusinessException e) {
log.error(e.getMessage());
}
try {
if (!CorePlugin.getDefault().isRepositoryInitialized()) {
ReturnCode rc = CorePlugin.getDefault().initProxyRepository();
if (!rc.isOk()) {
// $NON-NLS-1$
MessageDialog.openError(shell, DefaultMessagesImpl.getString("Application.warring"), rc.getMessage());
return IApplication.EXIT_OK;
}
}
// Tweaklets.setDefault(WorkbenchImplementation.KEY, new Workbench3xImplementation4CoolBar());
int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
}
return IApplication.EXIT_OK;
} finally {
display.dispose();
}
}
use of org.talend.commons.exception.BusinessException in project tdq-studio-se by Talend.
the class RenameSqlFileAction method run.
@Override
public void run() {
try {
// ADD xqliu 2012-05-24 TDQ-4831
if (this.node != null) {
if (WorkspaceResourceHelper.sourceFileHasBeenOpened(this.node)) {
MessageUI.openWarning(DefaultMessagesImpl.getString("SourceFileAction.sourceFileOpening", // $NON-NLS-1$
this.node.getLabel()));
return;
}
}
if (!ResourceManager.getRootProject().exists(filePath)) {
BusinessException createBusinessException = ExceptionFactory.getInstance().createBusinessException(this.filePath.toFile().getName());
throw createBusinessException;
}
// ~ TDQ-4831
RenameDialog dialog = new RenameDialog(Display.getDefault().getActiveShell());
existNames = new ArrayList<String>();
getExistNames(parentNode, existNames);
if (dialog.open() == RenameDialog.OK) {
try {
CorePlugin.getDefault().closeEditorIfOpened(sourceFiletem);
Project project = ProjectManager.getInstance().getCurrentProject();
if (!isNeedToMove(newFolderPath)) {
renameSourceFile(project);
} else {
moveSourceFile(project, newFolderPath);
}
CorePlugin.getDefault().refreshDQView(parentNode);
} catch (PersistenceException e) {
log.error(e);
} catch (BusinessException e) {
log.error(e);
}
}
} catch (BusinessException e) {
ExceptionHandler.process(e, Level.FATAL);
}
}
use of org.talend.commons.exception.BusinessException in project tdq-studio-se by Talend.
the class OpenItemEditorAction method duRun.
protected void duRun(IRepositoryNode repNode) throws BusinessException {
// TDQ-12200: fix a NPE when the open item is unsynchronized status(for example is deleted by others).
repositoryObjectCRUD.refreshDQViewForRemoteProject();
// TDQ-13357: fix NPE, because for ReportFileRepNode, repNode.getObject() == null
if (repNode.getObject() != null) {
if (repNode.getObject().getProperty() == null) {
repositoryObjectCRUD.showWarningDialog();
return;
}
// TDQ-12771: for local, also can avoid error when the cache node is changed but not save it.
try {
ProxyRepositoryFactory.getInstance().reload(repNode.getObject().getProperty());
IFile objFile = PropertyHelper.getItemFile(repNode.getObject().getProperty());
objFile.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (Exception e1) {
log.error(e1, e1);
}
}
// TDQ-12034~
IEditorInput itemEditorInput = computeEditorInput(repNode, true);
if (itemEditorInput != null) {
// open ItemEditorInput
CorePlugin.getDefault().openEditor(itemEditorInput, editorID);
} else {
// not find ItemEditorInput
if (repNode.getObject() == null) {
// open Report's genetated doc file
if (repNode != null && repNode instanceof ReportFileRepNode) {
ReportFileRepNode reportFileNode = (ReportFileRepNode) repNode;
IPath location = Path.fromOSString(reportFileNode.getResource().getRawLocation().toOSString());
// TDQ-5458 sizhaoliu 2012-07-17 add "." before the full name to make sure it is ignored by SVN.
IFile latestRepIFile = ResourceManager.getRootProject().getFile(PluginConstant.DOT_STRING + location.lastSegment());
try {
// TDQ-5458 sizhaoliu 2012-07-17 the link creation should be after report generation, but not at
// the openning.
// latestRepIFile.createLink(location, IResource.REPLACE, null);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
// MOD yyin 20121224 TDQ-5329, using the default editor setted by the user.
IDE.openEditor(page, latestRepIFile);
} catch (PartInitException e) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), // $NON-NLS-1$
Messages.getString("NewFolderWizard.failureTitle"), e.getMessage());
ExceptionHandler.process(e);
}
}
} else {
// if there don't found the correct ItemEditorInput and it is not Report's genetated doc file, try to
// open it as a File, this code will not be execute when method computeEditorInput() work well
IPath append = WorkbenchUtils.getFilePath(repNode.getObject().getRepositoryNode());
DQRepositoryNode node = (DQRepositoryNode) repNode.getObject().getRepositoryNode();
file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(append);
if (!file.exists()) {
throw ExceptionFactory.getInstance().createBusinessException(repNode.getObject());
}
try {
IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, true);
} catch (PartInitException e) {
log.error(e, e);
}
}
}
}
use of org.talend.commons.exception.BusinessException in project tdq-studio-se by Talend.
the class RunAnalysisAction method runAnalysisForItem.
/**
* DOC msjian Comment method "runAnalysisForItem".
*/
protected void runAnalysisForItem(final TDQAnalysisItem anaItem) {
try {
if (anaItem == null) {
// $NON-NLS-1$
log.error("Analysis item is null");
return;
}
if (ifLockByOthers(anaItem)) {
return;
}
// check if the analysis need to be saved or can run before real running by the event
if (!EventManager.getInstance().publish(anaItem.getAnalysis(), EventEnum.DQ_ANALYSIS_CHECK_BEFORERUN, null)) {
// or the analysis can not run, return without continue
return;
}
// to do validate after save.
validateAnalysis(anaItem);
if (!isConnectedAvailable(anaItem)) {
return;
}
if (log.isInfoEnabled()) {
addTaggedVaLueIntoConnection(anaItem);
}
AnalysisType analysisType = anaItem.getAnalysis().getParameters().getAnalysisType();
if (AnalysisType.COLUMNS_COMPARISON.equals(analysisType)) {
// If the analysis type is column comparison, ask user to continue to run or not.
if (!isContinueRun()) {
return;
}
} else if (AnalysisType.CONNECTION.equals(analysisType)) {
// If the analysis type is overview analysis, reload the database.
// TODO check here the needed of reloading database
reloadConnection(anaItem);
}
// when the run comes from context menu, the listener is null
if (this.listener == null && !ProxyRepositoryManager.getInstance().isLocked(anaItem)) {
if (!ProxyRepositoryFactory.getInstance().isEditableAndLockIfPossible(anaItem)) {
// if the analysis is not editable , return without running.
isNeedUnlock = false;
return;
} else {
// it is locked here, means that it need the unlock too.
isNeedUnlock = true;
}
} else {
isNeedUnlock = false;
}
final WorkspaceJob job = new // $NON-NLS-1$
WorkspaceJob(// $NON-NLS-1$
"Run Analysis") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
final boolean isSupportDynamicChart = isSupportDynamicChart(anaItem);
monitor.beginTask(DefaultMessagesImpl.getString("RunAnalysisAction.running", anaItem.getAnalysis().getName()), // $NON-NLS-1$
100);
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (listener != null) {
listener.fireRuningItemChanged(false, isSupportDynamicChart);
}
// register dynamic event for who supported dynamic chart
if (isSupportDynamicChart) {
EventManager.getInstance().publish(anaItem.getAnalysis(), EventEnum.DQ_DYNAMIC_REGISTER_DYNAMIC_CHART, null);
}
}
});
ReturnCode executed = null;
try {
monitor.worked(10);
executed = AnalysisExecutorSelector.executeAnalysis(anaItem, monitor);
if (monitor.isCanceled()) {
TdqAnalysisConnectionPool.closeConnectionPool(anaItem.getAnalysis());
// $NON-NLS-1$
executed = new ReturnCode(DefaultMessagesImpl.getString("RunAnalysisAction.TaskCancel"), false);
monitor.done();
if (isNeedUnlock) {
unlockAnalysis(anaItem);
}
return Status.CANCEL_STATUS;
}
if (isNeedUnlock) {
unlockAnalysis(anaItem);
}
// $NON-NLS-1$
monitor.subTask(DefaultMessagesImpl.getString("RunAnalysisAction.refresh.page"));
} finally {
// if any exception, still need to unregister dynamic events.
Display.getDefault().syncExec(new Runnable() {
public void run() {
// the analysis
if (isSupportDynamicChart) {
EventManager.getInstance().publish(anaItem.getAnalysis(), EventEnum.DQ_DYNAMIC_UNREGISTER_DYNAMIC_CHART, null);
}
if (listener != null) {
listener.fireRuningItemChanged(true);
} else {
// TODO yyin publish the event from listener.
EventManager.getInstance().publish(anaItem.getAnalysis(), EventEnum.DQ_ANALYSIS_RUN_FROM_MENU, null);
}
}
});
}
displayResultStatus(executed, anaItem);
// TODO move this code to the right place
addAnalysisToRef(anaItem.getAnalysis());
monitor.worked(20);
monitor.done();
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
// TDQ-11433: fix the job name still show after run analysis for remote project.(maybe this is not the best
// way to fix this issue)
job.addJobChangeListener(new JobChangeAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.runtime.jobs.JobChangeAdapter#done(org.eclipse.core.runtime.jobs.IJobChangeEvent)
*/
@Override
public void done(IJobChangeEvent event) {
// $NON-NLS-1$
job.setName("");
}
});
// TDQ-11433~
} catch (BusinessException e) {
ExceptionHandler.process(e, Level.FATAL);
}
}
use of org.talend.commons.exception.BusinessException in project tdq-studio-se by Talend.
the class DuplicateAction method doRun.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.AContextualAction#doRun()
*/
@Override
protected void doRun() {
repositoryObjectCRUD.refreshDQViewForRemoteProject();
// ADD msjian TDQ-7006 2013-7-24: after refresh get the selection to check.
if (!repositoryObjectCRUD.isSelectionAvailable()) {
repositoryObjectCRUD.showWarningDialog();
return;
}
try {
String newLabel = null;
Item lastDuplicateItem = null;
for (final IRepositoryNode node : nodeArray) {
IRepositoryViewObject viewObject = node.getObject();
validateOriginalObject(viewObject);
final IDuplicateHandle handle = ActionHandleFactory.getInstance().createDuplicateHandle(node);
if (handle != null) {
// MOD msjian TDQ-4672 2012-2-17: modified the check duplicate name method
String initLabel = generateInitialLabel(node);
InputDialog dialog = createInputNewNameDialog(node, initLabel);
// TDQ-4672~
if (dialog.open() == Window.OK) {
newLabel = dialog.getValue().trim();
lastDuplicateItem = handle.duplicateItem(viewObject.getProperty().getItem(), newLabel);
}
} else {
// if can not find the related handler for the current node, log it and continue for others
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("DuplicateAction.HandleNull", node.getLabel()));
}
}
// if the user select cancel, the item will be null, then no need to refresh.
if (lastDuplicateItem != null) {
CorePlugin.getDefault().refreshWorkSpace();
// show the last new success duplicated one as selected on the repository view.
selectAndReveal(newLabel, lastDuplicateItem);
}
} catch (BusinessException e) {
ExceptionHandler.process(e, Level.FATAL);
}
}
Aggregations