use of org.talend.core.ui.services.ISQLBuilderService in project tdi-studio-se by Talend.
the class NodeLabelEditPart method propertyChange.
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(final PropertyChangeEvent evt) {
String request = evt.getPropertyName();
if (request.equals(NodeLabel.OFFSET_CHANGE)) {
//$NON-NLS-1$ //$NON-NLS-2$
refreshVisuals();
getParent().refresh();
}
if (request.equals(NodeLabel.TEXT_CHANGE)) {
refreshVisuals();
// set the new size to update the node container
((NodeLabel) getModel()).setLabelSize(((SimpleHtmlFigure) figure).getPreferredSize());
NodeLabel label = (NodeLabel) getModel();
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISQLBuilderService.class)) {
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
service.updateSqlBuilderDialogTitle(label.getLabelText(), label.getNode().getProcess().getName(), label.getNode().getUniqueName());
}
getParent().refresh();
// refresh the title of component setting view.
ComponentSettingsView viewer = (ComponentSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ComponentSettingsView.ID);
if (viewer != null) {
viewer.updatePropertiesViewerTitle();
}
}
if (request.equals(NodeLabel.LOCATION)) {
//$NON-NLS-1$
refreshVisuals();
getParent().refresh();
}
if (request.equals(EParameterName.ACTIVATE.getName())) {
if (((NodeLabel) getModel()).isActivate()) {
((SimpleHtmlFigure) figure).setAlpha(-1);
((SimpleHtmlFigure) figure).repaint();
refreshVisuals();
} else {
((SimpleHtmlFigure) figure).setAlpha(Node.ALPHA_VALUE);
((SimpleHtmlFigure) figure).repaint();
refreshVisuals();
}
}
EditPart editPart = getParent();
if (editPart != null) {
while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
editPart = editPart.getParent();
}
if (editPart instanceof SubjobContainerPart) {
editPart.refresh();
}
}
}
use of org.talend.core.ui.services.ISQLBuilderService in project tdi-studio-se by Talend.
the class DbTableController method createOpenSQLCommand.
/**
* qzhang Comment method "createOpenSQLCommand".
*
* @param button
*/
protected void createOpenSQLCommand(Button button, IContextManager contextManager) {
final Button btn = button;
initConnectionParameters();
if (this.connParameters != null) {
if (isUseExistingConnection()) {
initConnectionParametersWithContext(connectionNode, contextManager.getDefaultContext());
} else {
initConnectionParametersWithContext(elem, contextManager.getDefaultContext());
}
DatabaseConnection connection = getExistConnection();
if (connection == null) {
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
connection = service.createConnection(connParameters);
}
boolean isStatus = false;
if (connection != null) {
String contextId = connection.getContextId();
if (contextId == null || "".equals(contextId)) {
IMetadataConnection metadataConnection = null;
metadataConnection = ConvertionHelper.convert(connection);
isStatus = checkConnection(metadataConnection);
} else {
isStatus = true;
}
}
if (isStatus) {
openSQLBuilderWithParamer(button);
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
//$NON-NLS-1$
String pid = "org.talend.sqlbuilder";
//$NON-NLS-1$
String mainMsg = "Database connection is failed. ";
ErrorDialogWithDetailAreaAndContinueButton dialog = new ErrorDialogWithDetailAreaAndContinueButton(composite.getShell(), pid, mainMsg, connParameters.getConnectionComment());
if (dialog.getCodeOfButton() == Window.OK) {
openParamemerDialog(btn, part.getProcess().getContextManager());
}
}
});
}
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
//$NON-NLS-1$
String pid = "org.talend.sqlbuilder";
//$NON-NLS-1$
String mainMsg = "Database connection is failed. ";
ErrorDialogWithDetailAreaAndContinueButton dialog = new ErrorDialogWithDetailAreaAndContinueButton(composite.getShell(), pid, mainMsg, connParameters.getConnectionComment());
if (dialog.getCodeOfButton() == Window.OK) {
openParamemerDialog(btn, part.getProcess().getContextManager());
}
}
});
}
}
use of org.talend.core.ui.services.ISQLBuilderService in project tdi-studio-se by Talend.
the class ActiveProcessTracker method partClosed.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void partClosed(IWorkbenchPart part) {
if (part instanceof AbstractMultiPageTalendEditor && currentProcess != null) {
AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
if (mpte.isKeepPropertyLocked()) {
currentProcess = null;
return;
}
IProcess process = getJobFromActivatedEditor(part);
if (process != null) {
Problems.removeProblemsByProcess(process);
Problems.removeJob(process);
IRunProcessService service = DesignerPlugin.getDefault().getRunProcessService();
service.removeProcess(process);
CodeView.refreshCodeView(null);
if (currentProcess == process) {
//$NON-NLS-1$
Contexts.setTitle("");
Contexts.clearAll();
if (lastProcessOpened == currentProcess) {
lastProcessOpened = null;
}
currentProcess = null;
for (IJobTrackerListener listener : jobTrackerListeners) {
listener.allJobClosed();
}
} else if (lastProcessOpened == process) {
lastProcessOpened = currentProcess;
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISQLBuilderService.class)) {
ISQLBuilderService sqlBuilderService = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
sqlBuilderService.closeSqlBuilderDialogs(process.getName());
}
}
} else if (part instanceof IEditorPart) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDiagramModelService.class) && CorePlugin.getDefault().getDiagramModelService().isBusinessDiagramEditor((IEditorPart) part)) {
//$NON-NLS-1$
Contexts.setTitle("");
Contexts.clearAll();
}
}
if (part instanceof AbstractMultiPageTalendEditor) {
AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
mpte.beforeDispose();
JobSettings.switchToCurJobSettingsView();
}
}
use of org.talend.core.ui.services.ISQLBuilderService 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.talend.core.ui.services.ISQLBuilderService in project tdi-studio-se by Talend.
the class AbstractElementPropertySectionController method isConnectionExist.
protected boolean isConnectionExist() {
ISQLBuilderService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISQLBuilderService.class)) {
service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
}
if (service == null) {
return false;
}
if (contextManager != null && contextManager.getDefaultContext().getContextParameterList().size() != 0) {
initConnectionParametersWithContext(elem, contextManager.getDefaultContext());
}
DatabaseConnection connection = service.createConnection(connParameters);
if (connection != null) {
IMetadataConnection metadataConnection = null;
metadataConnection = ConvertionHelper.convert(connection);
return checkExistConnections(metadataConnection);
}
return false;
}
Aggregations