use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.
the class JobScriptsExportWizardPage method finish.
// protected String getDestinationValueSU() {
// return this.suDestinationFilePath != null ? this.suDestinationFilePath : ""; //$NON-NLS-1$
//
// }
/**
* The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
* is returned then the wizard will not close.
*
* @returns boolean
*/
@Override
public boolean finish() {
// TODO
if (treeViewer != null) {
treeViewer.removeCheckStateListener(checkStateListener);
}
saveWidgetValues();
if (manager == null) {
manager = createJobScriptsManager();
}
if (!ensureTargetIsValid()) {
return false;
}
if (ensureLog4jSettingIsValid()) {
MessageDialog dialog = new MessageDialog(getShell(), "Question", null, Messages.getString("Log4jSettingPage.IlleagalBuild"), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
dialog.open();
int result = dialog.getReturnCode();
if (result != MessageDialog.OK) {
return false;
}
}
JobExportType jobExportType = getCurrentExportType1();
if (JobExportType.POJO.equals(jobExportType)) {
IRunnableWithProgress worker = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
buildJobWithMaven(JobExportType.POJO, monitor);
}
};
try {
getContainer().run(false, true, worker);
} catch (InvocationTargetException e) {
MessageBoxExceptionHandler.process(e.getCause(), getShell());
return false;
} catch (InterruptedException e) {
return false;
}
} else {
List<ContextParameterType> contextEditableResultValuesList = null;
if (manager != null) {
contextEditableResultValuesList = manager.getContextEditableResultValuesList();
}
if (nodes.length == 1) {
RepositoryNode node = nodes[0];
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
manager.setTopFolderName(ProjectManager.getInstance().getCurrentProject().getLabel());
} else {
manager.setTopFolderName(getDefaultFileNameWithType());
}
} else {
manager.setTopFolderName(getDefaultFileNameWithType());
}
// for feature:11976, recover back the old default manager value with ContextParameters
if (contextEditableResultValuesList == null) {
manager.setContextEditableResultValuesList(new ArrayList<ContextParameterType>());
} else {
manager.setContextEditableResultValuesList(contextEditableResultValuesList);
}
manager.setMultiNodes(isMultiNodes());
// achen modify to fix bug 0006222
IRunnableWithProgress worker = new JobExportAction(Arrays.asList(getCheckNodes()), getSelectedJobVersion(), manager, originalRootFolderName, getProcessType());
try {
getContainer().run(false, true, worker);
} catch (InvocationTargetException e) {
MessageBoxExceptionHandler.process(e.getCause(), getShell());
return false;
} catch (InterruptedException e) {
return false;
}
}
// see bug 7181
if (zipOption != null && zipOption.equals("true")) {
// unzip
try {
String zipFile;
if (manager != null) {
zipFile = manager.getDestinationPath();
} else {
zipFile = getDestinationValue();
int separatorIndex = zipFile.lastIndexOf(File.separator);
if (separatorIndex == -1) {
//$NON-NLS-1$
String userDir = System.getProperty("user.dir");
zipFile = userDir + File.separator + zipFile;
}
}
// Added by Marvin Wang on Feb.1, 2012 for bug TDI-18824
File file = new File(zipFile);
if (file.exists()) {
ZipToFile.unZipFile(zipFile, file.getParentFile().getAbsolutePath());
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e, getShell());
return false;
}
}
if (treeViewer != null) {
treeViewer.dispose();
}
// end
return true;
}
use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.
the class AbstractElementPropertySectionController method openSQLBuilder.
/**
* DOC qzhang Comment method "openSQLBuilder".
*
* @param repositoryType
* @param propertyName
* @param query
*/
protected String openSQLBuilder(String repositoryType, String propertyName, String query) {
if (repositoryType.equals(EmfComponent.BUILTIN)) {
connParameters.setQuery(query);
if (connParameters.isShowConfigParamDialog()) {
if (!isUseExistingConnection()) {
initConnectionParametersWithContext(elem, part.getProcess().getContextManager().getDefaultContext());
} else {
initConnectionParametersWithContext(connectionNode, part.getProcess().getContextManager().getDefaultContext());
}
}
// add for bug TDI-20335
if (part == null) {
Shell parentShell = new Shell(composite.getShell().getDisplay());
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, "", connParameters);
sqlBuilder.open();
} else {
openSqlBuilderBuildIn(connParameters, propertyName);
}
} else if (repositoryType.equals(EmfComponent.REPOSITORY)) {
//$NON-NLS-1$
String repositoryName2 = "";
String repositoryId = null;
IElementParameter memoParam = elem.getElementParameter(propertyName);
IElementParameter repositoryParam = null;
for (IElementParameter param : elem.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE && param.getRepositoryValue().startsWith("DATABASE")) {
repositoryParam = param;
break;
}
}
// in case no database property found, take the first property (to keep compatibility with old code)
if (repositoryParam == null) {
for (IElementParameter param : elem.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
repositoryParam = param;
break;
}
}
}
if (repositoryParam != null) {
IElementParameter itemFromRepository = repositoryParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
String value = (String) itemFromRepository.getValue();
repositoryId = value;
// for (String key : this.dynamicProperty.getRepositoryConnectionItemMap().keySet()) {
// if (key.equals(value)) {
// repositoryName2 =
// this.dynamicProperty.getRepositoryConnectionItemMap().get(key).getProperty().getLabel();
// }
// }
/* get connection item dynamictly,not from cache ,see 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
IRepositoryViewObject repobj = factory.getLastVersion(value);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
repositoryName2 = property.getLabel();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
// When no repository avaiable on "Repository" mode, open a MessageDialog.
if (repositoryName2 == null || repositoryName2.length() == 0) {
MessageDialog.openError(composite.getShell(), Messages.getString("NoRepositoryDialog.Title"), //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"NoRepositoryDialog.Text"));
return null;
}
// Part maybe not exist
//$NON-NLS-1$
String processName = "";
//$NON-NLS-1$
String key = "";
if (elem instanceof Node) {
processName = ((Node) elem).getProcess().getName();
key = processName + ((Node) elem).getUniqueName();
} else if (elem instanceof IProcess) {
processName = ((IProcess) elem).getName();
key = processName;
}
key += repositoryName2;
final Dialog builderDialog = sqlbuilers.get(key);
if (!composite.isDisposed() && builderDialog != null && builderDialog.getShell() != null && !builderDialog.getShell().isDisposed()) {
builderDialog.getShell().setActive();
} else {
connParameters.setRepositoryName(repositoryName2);
if (repositoryId != null) {
connParameters.setRepositoryId(repositoryId);
}
Shell parentShell = new Shell(composite.getShell().getDisplay());
String nodeLabel = null;
if (elem instanceof Node) {
nodeLabel = (String) ((Node) elem).getElementParameter(EParameterName.LABEL.getName()).getValue();
}
TextUtil.setDialogTitle(processName, nodeLabel, elem.getElementName());
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
connParameters.setQuery(query);
// first open Sql Builder,set true
connParameters.setFirstOpenSqlBuilder(true);
Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, processName, connParameters);
sqlbuilers.put(key, sqlBuilder);
if (Window.OK == sqlBuilder.open()) {
if (!composite.isDisposed() && !connParameters.isNodeReadOnly()) {
String sql = connParameters.getQuery();
// modified by hyWang
if (!connParameters.getIfContextButtonCheckedFromBuiltIn()) {
sql = QueryUtil.checkAndAddQuotes(sql);
}
return sql;
}
}
}
}
return null;
}
use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.
the class JavaProcessorUtilities method handleMissingJarsForProcess.
/**
*
* Added by Marvin Wang on Nov 7, 2012.
*
* @param missingJarsForRoutines
* @param missingJarsForProcess
* @param missingJars
* @throws BusinessException
*/
private static void handleMissingJarsForProcess(Set<String> missingJarsForRoutines, final Set<String> missingJarsForProcess, String missingJars) throws ProcessorException {
//$NON-NLS-1$
final StringBuffer sb = new StringBuffer("");
if (missingJarsForProcess.size() > 0) {
//$NON-NLS-1$
sb.append(Messages.getString("JavaProcessorUtilities.msg.missingjar.forProcess"));
for (String missingJar : missingJarsForProcess) {
sb.append(missingJar);
//$NON-NLS-1$
sb.append(", ");
}
if (missingJarsForRoutines.size() > 0) {
// subForMsg(sb.toString());
//$NON-NLS-1$
sb.append("\r\n\r\n\r\n");
//$NON-NLS-1$
sb.append(Messages.getString("JavaProcessorUtilities.msg.missingjar.note"));
//$NON-NLS-1$
sb.append("\r\n");
//$NON-NLS-1$
sb.append(Messages.getString("JavaProcessorUtilities.msg.missingjar.onlyforroutine"));
//$NON-NLS-1$
sb.append("\r\n");
for (String missingJar : missingJarsForRoutines) {
sb.append(missingJar);
//$NON-NLS-1$
sb.append(", ");
}
subForMsg(sb.toString());
} else {
subForMsg(sb.toString());
}
if (!CommonsPlugin.isHeadless()) {
Display display = DisplayUtils.getDisplay();
if (display != null) {
display.syncExec(new Runnable() {
@Override
public void run() {
// fix for TDI-24906
MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), Messages.getString("JavaProcessorUtilities.msg.missingjar.warningtitle"), null, subForMsg(sb.toString()), 4, new String[] { IDialogConstants.OK_LABEL }, 0) {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.window.Window#setShellStyle(int)
*/
@Override
protected void setShellStyle(int newShellStyle) {
super.setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL);
}
};
dialog.open();
}
});
}
} else {
throw new ProcessorException(missingJars);
}
} else {
if (missingJarsForRoutines.size() > 0) {
//$NON-NLS-1$
sb.append(Messages.getString("JavaProcessorUtilities.msg.missingjar.onlyforroutine"));
for (String missingJar : missingJarsForRoutines) {
sb.append(missingJar);
//$NON-NLS-1$
sb.append(", ");
}
CommonExceptionHandler.warn(subForMsg(sb.toString()));
}
}
}
use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.
the class CreateNodeContainerCommand method execute.
@Override
public void execute() {
if (this.location != null) {
this.nodeContainer.getNode().setLocation(this.location);
}
updatePaletteRecentlyUsedList();
AbstractProcessProvider provider = AbstractProcessProvider.findProcessProviderFromPID(nodeContainer.getNode().getComponent().getPluginExtension());
IElementParameter ep = nodeContainer.getNode().getElementParameter(EParameterName.UNIQUE_NAME.getName());
process.addUniqueNodeName(ep.getValue().toString());
if (provider == null || (provider != null && provider.containNodeInMemoryNotProcess())) {
this.process.addNodeContainer(this.nodeContainer);
process.checkStartNodes();
nodeContainer.getNode().checkAndRefreshNode();
refreshRelatedNodes();
// }
if (nodeContainer.getNode().getComponent().getComponentType() == EComponentType.JOBLET) {
IUpdateItemType jobletContextType = UpdateManagerProviderDetector.INSTANCE.getUpdateItemType(UpdateManagerHelper.TYPE_JOBLET_CONTEXT);
if (jobletContextType != null) {
process.getUpdateManager().update(jobletContextType);
}
}
} else {
String name = provider.getComponentProcess().getName() + " " + provider.getComponentProcess().getVersion();
MessageDialog warningMessageDialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Can't create node", null, "Joblet process " + name + " is not saved. Please save it first", MessageDialog.OK, new String[] { "OK" }, 0);
warningMessageDialog.open();
}
}
use of org.eclipse.jface.dialogs.MessageDialog in project cubrid-manager by CUBRID.
the class QueryEditorDNDController method openConfirmDialog.
/**
*
* Open confirm dialog
*
* @return the button id
*/
private int openConfirmDialog() {
String title = com.cubrid.common.ui.common.Messages.titleConfirm;
String[] buttons = new String[] { Messages.btnYes, Messages.btnNo, Messages.cancel };
MessageDialog dialog = new MessageDialog(editor.getSite().getShell(), title, null, Messages.changeDbConfirm, MessageDialog.QUESTION, buttons, 0) {
protected void buttonPressed(int buttonId) {
switch(buttonId) {
case 0:
setReturnCode(0);
close();
break;
case 1:
setReturnCode(1);
close();
break;
case 2:
setReturnCode(2);
close();
break;
default:
break;
}
}
};
return dialog.open();
}
Aggregations