use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestCSSContentAssistComputers method testAdditionalProposalInfo.
public void testAdditionalProposalInfo() throws Exception {
IFile file = getFile("test4.css");
StructuredTextEditor editor = getEditor(file);
StructuredTextViewer viewer = editor.getTextViewer();
int offset = viewer.getDocument().getLineLength(7) + 23;
ICompletionProposal[][] pages = getProposals(viewer, offset, 4);
assertTrue("Not enough pages", pages.length > 0);
ICompletionProposal[] proposals = pages[0];
for (int i = 0; i < proposals.length; i++) {
if (proposals[i] instanceof ICompletionProposalExtension5) {
Object obj = ((ICompletionProposalExtension5) proposals[i]).getAdditionalProposalInfo(null);
assertTrue("Additional info must be of type ProposalInfo", obj instanceof ProposalInfo);
ProposalInfo info = (ProposalInfo) obj;
assertNotNull("CSSMMNode for Proposal Info should not be null", info);
}
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class ViewerTestDTD method addActions.
protected void addActions(IContributionManager mgr) {
if (mgr != null) {
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "New HTML";
}
public void run() {
super.run();
BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {
public void run() {
setupViewerForNew();
fSourceViewer.setEditable(true);
}
});
}
});
mgr.add(new Separator());
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Change Visibility";
}
public void run() {
super.run();
NumberInputDialog dlg = new NumberInputDialog(fSourceViewer.getControl().getShell());
int proceed = dlg.open();
if (proceed == Window.CANCEL)
return;
fSourceViewer.resetVisibleRegion();
fSourceViewer.setVisibleRegion(dlg.startValue, dlg.lengthValue);
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Show All";
}
public void run() {
super.run();
fSourceViewer.resetVisibleRegion();
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Change Visibility in Editor";
}
public void run() {
super.run();
StructuredTextViewer sourceViewer = null;
IEditorPart part = getViewSite().getWorkbenchWindow().getActivePage().getActiveEditor();
if (part != null && part instanceof StructuredTextEditor) {
sourceViewer = ((StructuredTextEditor) part).getTextViewer();
}
if (sourceViewer != null) {
NumberInputDialog dlg = new NumberInputDialog(sourceViewer.getControl().getShell());
int proceed = dlg.open();
if (proceed == Window.CANCEL)
return;
sourceViewer.resetVisibleRegion();
sourceViewer.setVisibleRegion(dlg.startValue, dlg.lengthValue);
}
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Show All in Editor";
}
public void run() {
super.run();
StructuredTextViewer sourceViewer = null;
IEditorPart part = getViewSite().getWorkbenchWindow().getActivePage().getActiveEditor();
if (part != null && part instanceof StructuredTextEditor) {
sourceViewer = ((StructuredTextEditor) part).getTextViewer();
}
if (sourceViewer != null) {
sourceViewer.resetVisibleRegion();
}
}
});
mgr.add(new Separator());
// no longer able to set fInput to NULL
// mgr.add(new Action() {
// public String getText() {
// return getToolTipText();
// }
//
// public String getToolTipText() {
// return "Set Input to NULL";
// }
// public void run() {
// super.run();
// viewer.setInput(null);
// }
// });
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Take Input from Active Editor";
}
public void run() {
super.run();
ITextEditor textEditor = getActiveEditor();
if (textEditor != null) {
setupViewerForEditor(textEditor);
fSourceViewer.setEditable(true);
}
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Take Input and Follow Selection";
}
public void run() {
super.run();
followSelection();
fSourceViewer.setEditable(true);
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Take Input and Follow Selection As ReadOnly";
}
public void run() {
super.run();
followSelection();
fSourceViewer.setEditable(false);
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Stop Following Selection";
}
public void run() {
super.run();
stopFollowSelection();
}
});
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project liferay-ide by liferay.
the class WorkflowDefinitionEditor method _saveWorkflowDefinitionEntry.
private void _saveWorkflowDefinitionEntry(WorkflowDefinitionEditorInput definitionInput) {
StructuredTextEditor sourceEditor = getXmlEditor();
WorkflowDefinitionEntry definition = definitionInput.getWorkflowDefinitionEntry();
String titleMap = definition.getTitleMap();
String titleCurrentValue = definition.getTitleCurrentValue();
IDocumentProvider documentProvider = sourceEditor.getDocumentProvider();
IDocument document = documentProvider.getDocument(getEditorInput());
String definitionContent = document.get();
String[] newTitleMap = new String[1];
if ((titleCurrentValue != null) && (titleMap != null)) {
try {
String localeCode = Locale.getDefault().toString();
JSONObject jsonTitleMap = new JSONObject(titleMap);
Iterator<?> keys = jsonTitleMap.keys();
while ((keys != null) && keys.hasNext()) {
Object key = keys.next();
String value = jsonTitleMap.getString(key.toString());
if ((value != null) && value.contains(titleCurrentValue)) {
localeCode = key.toString();
break;
}
}
jsonTitleMap.put(localeCode, titleCurrentValue);
newTitleMap[0] = jsonTitleMap.toString();
} catch (Exception e) {
}
} else {
newTitleMap[0] = definition.getTitleMap();
}
if (empty(newTitleMap[0])) {
try {
newTitleMap[0] = KaleoUtil.createJSONTitleMap(definition.getTitle());
} catch (JSONException jsone) {
}
}
int draftVersion = definition.getDraftVersion() + 1;
if (draftVersion == 0) {
draftVersion = 1;
}
int newDraftVersion = draftVersion;
Job saveWorkflowEntry = new Job("Saving kaleo workflow entry.") {
@Override
protected IStatus run(IProgressMonitor monitor) {
IStatus retval = Status.OK_STATUS;
try {
JSONObject updatedDraftDefinition = null;
IKaleoConnection kaleoConnection = KaleoCore.getKaleoConnection(definition.getParent().getParent());
try {
JSONObject latestDraftDefinition = kaleoConnection.getLatestKaleoDraftDefinition(definition.getName(), definition.getVersion(), definition.getCompanyId());
if (latestDraftDefinition != null) {
updatedDraftDefinition = kaleoConnection.updateKaleoDraftDefinition(definition.getName(), newTitleMap[0], definitionContent, latestDraftDefinition.getInt("version"), latestDraftDefinition.getInt("draftVersion"), definition.getCompanyId(), definition.getUserId());
} else {
updatedDraftDefinition = kaleoConnection.addKaleoDraftDefinition(definition.getName(), newTitleMap[0], definitionContent, definition.getVersion(), newDraftVersion, definition.getUserId(), definition.getGroupId());
}
} catch (Exception e) {
updatedDraftDefinition = kaleoConnection.addKaleoDraftDefinition(definition.getName(), newTitleMap[0], definitionContent, definition.getVersion(), newDraftVersion, definition.getUserId(), definition.getGroupId());
}
WorkflowDefinitionEntry newNode = WorkflowDefinitionEntry.createFromJsObject(updatedDraftDefinition);
newNode.setParent(definition.getParent());
newNode.setCompanyId(definition.getCompanyId());
newNode.setContent(definitionContent);
newNode.setDraftVersion(newDraftVersion);
newNode.setName(definition.getName());
newNode.setLocation(definition.getLocation());
newNode.setTitleCurrentValue(titleCurrentValue);
newNode.setTitleMap(newTitleMap[0]);
newNode.setUserId(definition.getUserId());
newNode.setVersion(definition.getVersion());
newNode.setGroupId(definition.getGroupId());
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IEditorInput editInput = getEditorInput();
WorkflowDefinitionEditorInput workflowEditorInput = (WorkflowDefinitionEditorInput) editInput;
workflowEditorInput.setWorkflowDefinitionEntry(newNode);
setPartName(workflowEditorInput.getName());
firePropertyChange(propUpdateVersion);
}
});
} catch (Exception e) {
retval = KaleoUI.createErrorStatus("Could not save kaleo workflow entry.", e);
}
return retval;
}
};
saveWorkflowEntry.schedule();
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project syncope by apache.
the class TemplateEditor method createPage.
void createPage(final String inputString, final String title, final String tooltip) {
try {
if (title.equals(SyncopeView.TEMPLATE_FORMAT_HTML)) {
editor = new HTMLEditor();
} else {
editor = new StructuredTextEditor();
}
int index = addPage(editor, (IEditorInput) new TemplateEditorInput(inputString, title, tooltip));
setPageText(index, editor.getTitle());
} catch (final PartInitException e) {
ErrorDialog.openError(getSite().getShell(), ERROR_NESTED_EDITOR, null, e.getStatus());
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project mdw-designer by CenturyLinkCloud.
the class TaskTemplateEditor method init.
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
setSite(site);
textEditor = new StructuredTextEditor() {
@Override
public boolean isEditable() {
return false;
}
@Override
public boolean isEditorInputModifiable() {
return false;
}
@Override
public boolean isEditorInputReadOnly() {
return true;
}
@Override
public boolean isDirty() {
return false;
}
};
textEditor.setEditorPart(this);
if (input instanceof FileEditorInput) {
setInput(input);
IFile file = ((FileEditorInput) input).getFile();
WorkflowProject project = WorkflowProjectManager.getInstance().getWorkflowProject(file.getProject());
// force initialization
project.getDesignerProxy();
WorkflowPackage pkg = project.getPackage((IFolder) file.getParent());
taskTemplate = (TaskTemplate) pkg.getTaskTemplate(file);
// refresh from file system to make sure we're in sync
try {
Long taskId = taskTemplate.getId();
int version = taskTemplate.getVersion();
file.refreshLocal(IResource.DEPTH_ZERO, null);
String content = new String(PluginUtil.readFile(file));
TaskVO taskVO;
if (content.trim().startsWith("{")) {
taskVO = new TaskVO(new JSONObject(content));
} else {
TaskTemplateDocument doc = TaskTemplateDocument.Factory.parse(content);
com.centurylink.mdw.task.TaskTemplate fileTemplate = doc.getTaskTemplate();
taskVO = new TaskVO(fileTemplate);
}
taskTemplate.setTaskVO(taskVO);
taskVO.setName(file.getName());
taskVO.setTaskId(taskId);
taskTemplate.setId(taskId);
taskTemplate.setVersion(version);
taskVO.setPackageName(pkg.getName());
} catch (Exception ex) {
throw new PartInitException(ex.getMessage(), ex);
}
} else {
throw new PartInitException("Invalid input: " + input);
}
selectionProvider = new WorkflowSelectionProvider(taskTemplate);
site.setSelectionProvider(selectionProvider);
setPartName(taskTemplate.getName());
addPageChangedListener(new IPageChangedListener() {
public void pageChanged(PageChangedEvent event) {
if (getSelectedPage() == pages.get("Variables")) {
reconcileVariables();
}
}
});
partListener = new IPartListener2() {
public void partOpened(IWorkbenchPartReference partRef) {
// do nothing
}
public void partActivated(IWorkbenchPartReference partRef) {
IWorkbenchPart part = partRef.getPart(false);
if (part == TaskTemplateEditor.this && getSelectedPage() == pages.get("Variables"))
reconcileVariables();
}
public void partBroughtToTop(IWorkbenchPartReference partRef) {
// do nothing
}
public void partDeactivated(IWorkbenchPartReference partRef) {
// do nothing
}
public void partClosed(IWorkbenchPartReference partRef) {
// do nothing
}
public void partVisible(IWorkbenchPartReference partRef) {
// do nothing
}
public void partHidden(IWorkbenchPartReference partRef) {
// do nothing
}
public void partInputChanged(IWorkbenchPartReference partRef) {
// do nothing
}
};
getSite().getPage().addPartListener(partListener);
workbenchListener = new IWorkbenchListener() {
public boolean preShutdown(IWorkbench workbench, boolean forced) {
return MdwPlugin.getActivePage().closeEditor(TaskTemplateEditor.this, true);
}
public void postShutdown(IWorkbench workbench) {
// do nothing
}
};
PlatformUI.getWorkbench().addWorkbenchListener(workbenchListener);
}
Aggregations