use of org.eclipse.ui.IEditorInput in project tesb-studio-se by Talend.
the class OpenAnotherVersionResourceAction method getCorrespondingEditor.
protected IEditorPart getCorrespondingEditor(RepositoryNode node) {
for (IEditorReference ref : getActivePage().getEditorReferences()) {
try {
IEditorInput input = ref.getEditorInput();
if (!(input instanceof RouteResourceInput)) {
continue;
}
RouteResourceInput repositoryInput = (RouteResourceInput) input;
if (repositoryInput.getItem().equals(node.getObject().getProperty().getItem())) {
return ref.getEditor(false);
}
} catch (PartInitException e) {
continue;
}
}
return null;
}
use of org.eclipse.ui.IEditorInput in project tesb-studio-se by Talend.
the class CamelEditorDropTargetListener method createContext.
private void createContext() {
if (selectSourceList.size() == 0) {
return;
}
boolean created = false;
for (Object source : selectSourceList) {
if (source instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) source;
Item item = sourceNode.getObject().getProperty().getItem();
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
EList context = contextItem.getContext();
Set<String> contextSet = new HashSet<String>();
Iterator iterator = context.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
EList contextParameters = ((ContextTypeImpl) obj).getContextParameter();
Iterator contextParas = contextParameters.iterator();
while (contextParas.hasNext()) {
ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
String name = contextParameterType.getName();
contextSet.add(name);
}
}
}
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof JobEditorInput) {
JobEditorInput jobInput = (JobEditorInput) editorInput;
IProcess2 process = jobInput.getLoadedProcess();
IContextManager contextManager = process.getContextManager();
List<IContext> listContext = contextManager.getListContext();
Set<String> addedVars = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextSet, process.getContextManager(), false);
if (addedVars != null && !addedVars.isEmpty() && !ConnectionContextHelper.isAddContextVar(contextItem, contextManager, contextSet)) {
// show
Map<String, Set<String>> addedVarsMap = new HashMap<String, Set<String>>();
addedVarsMap.put(item.getProperty().getLabel(), contextSet);
if (ConnectionContextHelper.showContextdialog(process, contextItem, process.getContextManager(), addedVarsMap, contextSet)) {
created = true;
}
} else {
//$NON-NLS-1$
MessageDialog.openInformation(//$NON-NLS-1$
editor.getEditorSite().getShell(), //$NON-NLS-1$
"Adding Context", //$NON-NLS-1$
"Context \"" + contextItem.getProperty().getDisplayName() + "\" already exist.");
}
}
}
}
}
if (created) {
RepositoryPlugin.getDefault().getDesignerCoreService().switchToCurContextsView();
}
}
use of org.eclipse.ui.IEditorInput in project tesb-studio-se by Talend.
the class LocalWSDLEditor method dispose.
@Override
public void dispose() {
// unlock item if necessary
IEditorInput currentEditorInput = getEditorInput();
if (currentEditorInput instanceof RepositoryEditorInput) {
RepositoryEditorInput serviceEditorInput = (RepositoryEditorInput) currentEditorInput;
Item currentItem = serviceEditorInput.getItem();
if (currentItem != null) {
// unlock item if no other editors open it.
boolean openItemInOtherEditor = false;
IEditorReference[] editorRefs = getEditorSite().getPage().getEditorReferences();
for (IEditorReference editorRef : editorRefs) {
if (editorRef.getEditor(false) == this) {
continue;
}
try {
IEditorInput editorInput = editorRef.getEditorInput();
if (editorInput instanceof RepositoryEditorInput) {
Item item = ((RepositoryEditorInput) editorInput).getItem();
if (item == currentItem) {
// open this item & not this one.
openItemInOtherEditor = true;
}
}
} catch (PartInitException e) {
// ignore and compare others
ExceptionHandler.process(e);
}
}
if (!openItemInOtherEditor) {
try {
DesignerPlugin.getDefault().getProxyRepositoryFactory().unlock(currentItem);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
super.dispose();
}
use of org.eclipse.ui.IEditorInput in project bndtools by bndtools.
the class AbstractLaunchShortcut method launch.
@Override
public void launch(IEditorPart editor, String mode) {
IEditorInput input = editor.getEditorInput();
IJavaElement element = (IJavaElement) input.getAdapter(IJavaElement.class);
if (element != null) {
IJavaProject jproject = element.getJavaProject();
if (jproject != null) {
launch(jproject.getProject().getFullPath(), jproject.getProject(), mode);
}
} else {
IFile file = ResourceUtil.getFile(input);
if (file != null) {
if (file.getName().endsWith(LaunchConstants.EXT_BNDRUN)) {
launch(file.getFullPath(), file.getProject(), mode);
} else if (file.getName().equals(Project.BNDFILE)) {
launch(file.getProject().getFullPath(), file.getProject(), mode);
}
}
}
}
use of org.eclipse.ui.IEditorInput in project bndtools by bndtools.
the class RunRequirementsPart method doResolve.
private void doResolve() {
// Make sure all the parts of this editor page have committed their
// dirty state to the model
IFormPart[] parts = getManagedForm().getParts();
for (IFormPart part : parts) {
if (part.isDirty())
part.commit(false);
}
final IFormPage page = (IFormPage) getManagedForm().getContainer();
final IEditorInput input = page.getEditorInput();
final IEditorPart editor = page.getEditor();
final IFile file = ResourceUtil.getFile(input);
final Shell parentShell = page.getEditor().getSite().getShell();
// Create the wizard and pre-validate
final ResolveJob job = new ResolveJob(model);
IStatus validation = job.validateBeforeRun();
if (!validation.isOK()) {
ErrorDialog errorDialog = new ErrorDialog(parentShell, "Validation Problem", null, validation, IStatus.ERROR | IStatus.WARNING) {
@Override
protected void createButtonsForButtonBar(Composite parent) {
// create OK, Cancel and Details buttons
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
createDetailsButton(parent);
}
};
int response = errorDialog.open();
if (Window.CANCEL == response || validation.getSeverity() >= IStatus.ERROR) {
btnResolveNow.setEnabled(true);
return;
}
}
// Add the operation to perform at the end of the resolution job (i.e.,
// showing the result)
final Runnable showResult = new Runnable() {
@Override
public void run() {
ResolutionWizard wizard = new ResolutionWizard(model, file, job.getResolutionResult());
WizardDialog dialog = new WizardDialog(parentShell, wizard);
boolean dirtyBeforeResolve = editor.isDirty();
if (dialog.open() == Dialog.OK && !dirtyBeforeResolve) {
// only save the editor, when no unsaved changes happened before resolution
editor.getEditorSite().getPage().saveEditor(editor, false);
}
btnResolveNow.setEnabled(true);
}
};
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
Outcome outcome = job.getResolutionResult().getOutcome();
if (outcome != Outcome.Cancelled)
parentShell.getDisplay().asyncExec(showResult);
}
});
job.setUser(true);
job.schedule();
}
Aggregations