use of org.eclipse.ui.PartInitException in project tdi-studio-se by Talend.
the class ReadRoutineAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
if (repositoryNode == null && getSelection() != null) {
repositoryNode = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
}
RoutineItem routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(routineItem)), routineItem.getProperty().getId()).getProperty();
// repositoryNode.getObject().setProperty(updatedProperty);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
try {
openRoutineEditor(routineItem, true);
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
} catch (SystemException e) {
MessageBoxExceptionHandler.process(e);
}
}
use of org.eclipse.ui.PartInitException in project tesb-studio-se by Talend.
the class RouteResourceEditorUtil method findPreferEditor.
/**
* find a prefer editor from all existing editors according to the
* fileExtensions
*
* @param fileExtension
* @return
*/
private String findPreferEditor(RouteResourceInput fileEditorInput) {
String editorId = RouteResourceEditor.ID;
Object underlingFile = fileEditorInput.getAdapter(IFile.class);
if (underlingFile == null) {
return editorId;
}
IEditorDescriptor ed = null;
try {
ed = IDE.getEditorDescriptor((IFile) underlingFile, true);
} catch (PartInitException e) {
return editorId;
}
if (ed == null) {
return editorId;
}
String id = ed.getId();
if (id == null || id.trim() == null) {
return editorId;
}
return id;
}
use of org.eclipse.ui.PartInitException in project tdi-studio-se by Talend.
the class SQLBuilderTabComposite method createTabItem.
/**
* Creates tab item. Changed by Marvin Wang on Feb. 24, 2012 for bug TDI-7643, for all SQLBuilderEditorComposite
* when using <code>editorComposite.getConnParam().getQueryObject()</code> to get the query object, the query every
* time get is the same object. Caz all <code>SQLBuilderEditorComposite</code>s use the same connection parameter.
*
* @param node
* @param connParam
* @param isDefaultEditor
*/
private void createTabItem(RepositoryNode node, ConnectionParameters connParam, boolean isDefaultEditor) {
//$NON-NLS-1$
String queryStr = "";
if (node != null) {
CTabItem[] tabItems = tabFolder.getItems();
for (int i = 0; i < tabItems.length; i++) {
SQLBuilderEditorComposite editorComposite = (SQLBuilderEditorComposite) (((CTabFolder) tabItems[i].getControl()).getItems()[0]).getControl();
// To get the different query object for each SQLBuilderEditorComposite, use the following method. The
// queryObject is stored in <code>SQLBuilderEditorComposite.doSaveSQL()</code>
Query query2 = editorComposite.getQueryObject();
if ((RepositoryNodeType) node.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.QUERY) {
Query query = ((QueryRepositoryObject) node.getObject()).getQuery();
if (query2 == null && tabItems[i].getData() instanceof Query) {
query2 = (Query) tabItems[i].getData();
}
if (query2 != null && query.getLabel().equals(query2.getLabel())) {
if ("".equals(editorComposite.getEditorContent())) {
//$NON-NLS-1$
editorComposite.setEditorContent(query.getValue());
}
tabFolder.setSelection(i);
return;
}
connParam.setQueryObject(query);
queryStr = query.getValue();
}
}
}
CTabItem tabItem = null;
if (connParam.isFromDBNode()) {
tabItem = new CTabItem(tabFolder, SWT.NULL);
} else {
tabItem = new CTabItem(tabFolder, SWT.CLOSE);
}
node = SQLBuilderRepositoryNodeManager.getRoot(node);
if (!"".equals(queryStr)) {
//$NON-NLS-1$
try {
nodesSel = EMFRepositoryNodeManager.getInstance().parseSqlStatement(queryStr, node);
} catch (Exception e) {
MessageDialog.openError(new Shell(), Messages.getString("SQLBuilderTabComposite.Notice.title"), //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"SQLBuilderTabComposite.Notice.Info"));
}
}
MultiPageSqlBuilderEditor builderEditor = new MultiPageSqlBuilderEditor(nodesSel, tabItem, isDefaultEditor, connParam, node, dialog);
builderEditor.setReadOnly(readOnly);
try {
builderEditor.init(new SQLBuilderEditorSite(), new SQLBuilderEditorInput());
} catch (PartInitException e) {
ExceptionHandler.process(e);
}
builderEditor.createPartControl2(tabFolder);
tabItem.setControl(builderEditor.getContainer());
tabItem.setData(TextUtil.KEY, builderEditor);
if (connParam.isFromRepository() && connParam.getQueryObject() != null) {
queryStr = connParam.getQueryObject().getValue();
}
builderEditor.setSqlText(queryStr);
if (connParam.isShowDesignerPage()) {
builderEditor.showDesignerPage();
}
// set new tab as the active one.
tabFolder.setSelection(tabFolder.getItemCount() - 1);
// refresh view
tabFolder.layout();
tabFolder.redraw();
}
use of org.eclipse.ui.PartInitException in project tdi-studio-se by Talend.
the class SQLPatternComposite method resourceChanged.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent
* )
*/
@Override
public void resourceChanged(IResourceChangeEvent event) {
boolean needRefresh = false;
boolean modifySQL = true;
if (event.getSource() instanceof SQLPatternItem && event.getType() == IResourceChangeEvent.PRE_CLOSE) {
needRefresh = true;
modifySQL = false;
// if still have sql template editor to be opened.
if (getCurrentOpenedEditors() != null) {
for (IEditorReference editor : getCurrentOpenedEditors()) {
ERepositoryObjectType type = null;
try {
type = getCurrentOpenEditorType(editor);
} catch (PartInitException e) {
e.printStackTrace();
}
if (type != null && ERepositoryObjectType.SQLPATTERNS.equals(type)) {
modifySQL = true;
}
}
}
}
if (event.getSource() instanceof SQLPatternItem && event.getType() == IResourceChangeEvent.POST_CHANGE) {
needRefresh = true;
}
if (needRefresh) {
refreshComboContent(this.tableViewer, modifySQL);
refresh();
}
}
use of org.eclipse.ui.PartInitException in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method turnToJobScriptPage.
protected void turnToJobScriptPage(int newPageIndex) {
if (jobletEditor != getEditor(newPageIndex)) {
return;
}
ICreateXtextProcessService convertJobtoScriptService = CorePlugin.getDefault().getCreateXtextProcessService();
try {
final String scriptValue = convertJobtoScriptService.convertJobtoScript(getProcess().saveXmlFile());
IFile file = (IFile) jobletEditor.getEditorInput().getAdapter(IResource.class);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(scriptValue.getBytes());
if (file.exists()) {
jobletEditor.getDocumentProvider().getDocument(jobletEditor.getEditorInput()).set(scriptValue);
boolean isProcessReadOnly = ((JobEditorInput) getEditor(0).getEditorInput()).isReadOnly();
IProxyRepositoryFactory rFactory = ProxyRepositoryFactory.getInstance();
if (isProcessReadOnly || rFactory.isUserReadOnlyOnCurrentProject()) {
IDocumentProvider provider = jobletEditor.getDocumentProvider();
Class p = provider.getClass();
Class[] type = new Class[1];
type[0] = Boolean.TYPE;
Object[] para = new Object[1];
para[0] = Boolean.TRUE;
Method method = p.getMethod("setReadOnly", type);
method.invoke(provider, para);
}
//$NON-NLS-1$
IAction action = jobletEditor.getAction("FoldingRestore");
action.run();
jobletEditor.doSave(null);
} else {
file.create(byteArrayInputStream, true, null);
}
if (propertyListener == null) {
propertyListener = new IPropertyListener() {
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof IEditorPart && ((IEditorPart) source).isDirty()) {
getProcess().setProcessModified(true);
getProcess().setNeedRegenerateCode(true);
}
}
};
jobletEditor.addPropertyListener(propertyListener);
}
} catch (PartInitException e) {
ExceptionHandler.process(e);
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
} catch (SecurityException e) {
ExceptionHandler.process(e);
} catch (NoSuchMethodException e) {
ExceptionHandler.process(e);
} catch (IllegalArgumentException e) {
ExceptionHandler.process(e);
} catch (IllegalAccessException e) {
ExceptionHandler.process(e);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
}
changeContextsViewStatus(false);
}
Aggregations