use of org.eclipse.jface.action.IAction in project yamcs-studio by yamcs.
the class CopyWidgetsAction method run.
@Override
public void run() {
DisplayModel tempModel = new DisplayModel();
List<AbstractWidgetModel> widgetModels = getSelectedWidgetModels();
for (AbstractWidgetModel widget : widgetModels) {
tempModel.addChild(widget, false);
}
String xml = XMLUtil.widgetToXMLString(tempModel, false);
((OPIEditor) getWorkbenchPart()).getClipboard().setContents(new Object[] { xml }, new Transfer[] { OPIWidgetsTransfer.getInstance() });
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
IAction pasteAction = ((ActionRegistry) ((OPIEditor) getWorkbenchPart()).getAdapter(ActionRegistry.class)).getAction(ActionFactory.PASTE.getId());
if (pasteAction != null) {
((PasteWidgetsAction) pasteAction).refreshEnable();
}
}
});
}
use of org.eclipse.jface.action.IAction in project liferay-ide by liferay.
the class IDEFormPage method createFormContent.
protected void createFormContent(IManagedForm managedForm) {
ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
toolkit.decorateFormHeading(form.getForm());
IToolBarManager manager = form.getToolBarManager();
getFormEditor().contributeToToolbar(manager);
IFormPart[] parts = managedForm.getParts();
for (int i = 0; i < parts.length; i++) {
if (parts[i] instanceof IAdaptable) {
IAdaptable adapter = (IAdaptable) parts[i];
IAction[] actions = (IAction[]) adapter.getAdapter(IAction[].class);
if (actions != null) {
for (int j = 0; j < actions.length; j++) {
form.getToolBarManager().add(actions[j]);
}
}
}
}
form.updateToolBar();
}
use of org.eclipse.jface.action.IAction in project liferay-ide by liferay.
the class ServiceMethodHyperlinkDetector method detectHyperlinks.
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
IHyperlink[] retval = null;
ITextEditor textEditor = (ITextEditor) getAdapter(ITextEditor.class);
if (textEditor == null) {
return retval;
}
ITypeRoot input = EditorUtility.getEditorInputJavaElement(textEditor, false);
IAction openAction = textEditor.getAction("OpenEditor");
if (_shouldDetectHyperlinks(textEditor, input, openAction, region)) {
IDocumentProvider documentProvider = textEditor.getDocumentProvider();
IEditorInput editorInput = textEditor.getEditorInput();
IDocument document = documentProvider.getDocument(editorInput);
int offset = region.getOffset();
IRegion wordRegion = JavaWordFinder.findWord(document, offset);
if (_isRegionValid(document, wordRegion)) {
IJavaElement[] elements = new IJavaElement[0];
long modStamp = documentProvider.getModificationStamp(editorInput);
if (input.equals(_lastInput) && (modStamp == _lastModStamp) && wordRegion.equals(_lastWordRegion)) {
elements = _lastElements;
} else {
try {
elements = ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion.getLength());
elements = _selectOpenableElements(elements);
_lastInput = input;
_lastModStamp = modStamp;
_lastWordRegion = wordRegion;
_lastElements = elements;
} catch (JavaModelException jme) {
}
}
if (elements.length != 0) {
List<IHyperlink> links = new ArrayList<>(elements.length);
for (IJavaElement element : elements) {
if (element instanceof IMethod) {
_addHyperlinks(links, wordRegion, (SelectionDispatchAction) openAction, (IMethod) element, elements.length > 1, (JavaEditor) textEditor);
}
}
if (ListUtil.isNotEmpty(links)) {
if (canShowMultipleHyperlinks) {
retval = links.toArray(new IHyperlink[0]);
} else {
retval = new IHyperlink[] { links.get(0) };
}
}
}
}
}
return retval;
}
use of org.eclipse.jface.action.IAction in project liferay-ide by liferay.
the class FindBreakingChangesPage method createTableView.
public void createTableView(Composite container) {
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.minimumWidth = 200;
gridData.minimumHeight = 200;
Composite tableComposite = new Composite(container, SWT.NONE);
_problemsViewer = new TableViewer(tableComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL);
_problemsViewer.getTable().setLayoutData(gridData);
_createColumns(_problemsViewer);
final Table table = _problemsViewer.getTable();
table.setHeaderVisible(true);
_problemsViewer.setContentProvider(ArrayContentProvider.getInstance());
_problemsViewer.setComparer(null);
_comparator = new MigratorComparator();
_problemsViewer.setComparator(_comparator);
MenuManager menuMgr = new MenuManager();
IAction markDoneAction = new MarkDoneAction(_problemsViewer);
IAction markUndoneAction = new MarkUndoneAction(_problemsViewer);
IAction ignoreAction = new IgnoreAction(_problemsViewer);
IAction ignoreAlways = new IgnoreAlwaysAction(_problemsViewer);
IAction autoCorrectAction = new AutoCorrectAction(_problemsViewer);
menuMgr.add(markDoneAction);
menuMgr.add(markUndoneAction);
menuMgr.add(ignoreAction);
menuMgr.add(autoCorrectAction);
menuMgr.add(ignoreAlways);
Menu menu = menuMgr.createContextMenu(table);
table.setMenu(menu);
_problemsViewer.addDoubleClickListener(this);
}
use of org.eclipse.jface.action.IAction in project liferay-ide by liferay.
the class UpgradeView method createPartControl.
@Override
public void createPartControl(Composite parent) {
ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.DOUBLE_BUFFERED | SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
Composite container = SWTUtil.createComposite(scrolledComposite, 1, 0, GridData.FILL_BOTH);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.marginWidth = 0;
gridLayout.marginTop = 0;
gridLayout.marginHeight = 0;
container.setLayout(gridLayout);
Composite composite = new Composite(container, SWT.NONE);
composite.setLayout(new GridLayout(1, true));
GridData grData = new GridData(GridData.FILL_BOTH);
grData.grabExcessVerticalSpace = true;
grData.grabExcessHorizontalSpace = true;
composite.setLayoutData(grData);
final GearControl gear = new GearControl(composite, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.grabExcessHorizontalSpace = true;
gridData.widthHint = 400;
gridData.heightHint = 150;
gear.setLayoutData(gridData);
gear.setBackground(parent.getBackground());
StackLayout stackLayout = new StackLayout();
_pagesSwitchControler = new Composite(composite, SWT.BORDER);
_pagesSwitchControler.setLayout(stackLayout);
GridData containerData = new GridData(GridData.FILL_BOTH);
containerData.grabExcessHorizontalSpace = true;
containerData.grabExcessVerticalSpace = true;
containerData.grabExcessHorizontalSpace = true;
_pagesSwitchControler.setLayoutData(containerData);
int pageIndex = 0;
Page welcomePage = new WelcomePage(_pagesSwitchControler, SWT.NONE, _dataModel);
welcomePage.setIndex(pageIndex++);
welcomePage.setTitle("Welcome");
welcomePage.setBackPage(false);
welcomePage.addPageNavigateListener(gear);
Page initConfigureProjectPage = new InitConfigureProjectPage(_pagesSwitchControler, SWT.NONE, _dataModel);
initConfigureProjectPage.setIndex(pageIndex++);
initConfigureProjectPage.setTitle("Select project(s) to upgrade");
initConfigureProjectPage.addPageNavigateListener(gear);
initConfigureProjectPage.addPageValidationListener(gear);
initConfigureProjectPage.setNextPage(false);
Page upgradePomPage = new UpgradePomPage(_pagesSwitchControler, SWT.NONE, _dataModel);
upgradePomPage.setIndex(pageIndex++);
upgradePomPage.setTitle("Upgrade POM Files");
upgradePomPage.addPageValidationListener(gear);
Page findBreakingChangesPage = new FindBreakingChangesPage(_pagesSwitchControler, SWT.NONE, _dataModel);
findBreakingChangesPage.setIndex(pageIndex++);
findBreakingChangesPage.setTitle("Find Breaking Changes");
Page descriptorsPage = new DescriptorsPage(_pagesSwitchControler, SWT.NONE, _dataModel);
descriptorsPage.setIndex(pageIndex++);
descriptorsPage.setTitle("Update Descriptor Files");
descriptorsPage.addPageValidationListener(gear);
Page buildServicePage = new BuildServicePage(_pagesSwitchControler, SWT.NONE, _dataModel);
buildServicePage.setIndex(pageIndex++);
buildServicePage.setTitle("Build Services");
Page layoutTemplatePage = new LayoutTemplatePage(_pagesSwitchControler, SWT.NONE, _dataModel);
layoutTemplatePage.setIndex(pageIndex++);
layoutTemplatePage.setTitle("Layout Templates");
layoutTemplatePage.addPageValidationListener(gear);
Page customJspPage = new CustomJspPage(_pagesSwitchControler, SWT.NONE, _dataModel);
customJspPage.setIndex(pageIndex++);
customJspPage.setTitle("Custom Jsp");
customJspPage.addPageValidationListener(gear);
// Page extAndThemePage = new ExtAndThemePage( pagesSwitchControler, SWT.NONE,
// dataModel );
// extAndThemePage.setIndex( 7 );
// extAndThemePage.setTitle( "Ext and Theme" );
Page buildPage = new BuildPage(_pagesSwitchControler, SWT.NONE, _dataModel);
buildPage.setIndex(pageIndex++);
buildPage.setTitle("Build");
Page summaryPage = new SummaryPage(_pagesSwitchControler, SWT.NONE, _dataModel);
summaryPage.setIndex(pageIndex++);
summaryPage.setTitle("Summary");
summaryPage.setNextPage(false);
summaryPage.addPageNavigateListener(gear);
_staticPageList.clear();
_staticPageList.add(welcomePage);
_staticPageList.add(initConfigureProjectPage);
_staticPageList.add(upgradePomPage);
_staticPageList.add(findBreakingChangesPage);
_staticPageList.add(descriptorsPage);
_staticPageList.add(buildServicePage);
_staticPageList.add(layoutTemplatePage);
_staticPageList.add(customJspPage);
// staticPageList.add( extAndThemePage );
_staticPageList.add(buildPage);
_staticPageList.add(summaryPage);
resetPages();
final NavigatorControl navigator = new NavigatorControl(composite, SWT.NONE);
navigator.addPageNavigateListener(gear);
navigator.addPageActionListener(gear);
navigator.setBackground(parent.getBackground());
_staticPageList.stream().forEach(navigator::addPageActionListener);
gear.addSelectionChangedListener(navigator);
gear.addSelectionChangedListener(this);
gear.addSelectionChangedListener(initConfigureProjectPage);
gear.addSelectionChangedListener(descriptorsPage);
gear.addSelectionChangedListener(upgradePomPage);
gear.addSelectionChangedListener(layoutTemplatePage);
gear.addSelectionChangedListener(summaryPage);
GridData navData = new GridData(GridData.FILL_HORIZONTAL);
navData.grabExcessHorizontalSpace = true;
navigator.setLayoutData(navData);
scrolledComposite.setContent(container);
// scrolledComposite.setMinSize(container.computeSize(SWT.DEFAULT, 670));
setSelectPage(0);
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
int pageNum = getPageNumber();
for (int i = 0; i < pageNum; i++) {
Page page = UpgradeView.getPage(i);
String pageId = page.getPageId();
PageAction pageAction = page.getSelectedAction();
if (pageAction != null) {
UpgradeSettingsUtil.storeProperty(pageId, pageAction.getPageActionName());
}
}
}
});
IActionBars actionBars = getViewSite().getActionBars();
final IToolBarManager mgr = actionBars.getToolBarManager();
final IAction restart = new Action("Restart Upgrade", ImageDescriptor.createFromURL(bundle.getEntry("icons/e16/restart.gif"))) {
@Override
public void run() {
_restartUpgradeTool();
}
};
final IAction showAllPages = new Action("Show All Pages", ImageDescriptor.createFromURL(bundle.getEntry("icons/e16/showall.gif"))) {
@Override
public void run() {
StringBuilder desriptors = new StringBuilder("If you fail to import projects, you can skip step 2 by ");
desriptors.append("doing the following steps:\n");
desriptors.append(" 1.upgrade SDK 6.2 to SDK 7.0 manually\n");
desriptors.append(" or use blade cli to create a Liferay workspace for your SDK\n");
desriptors.append(" 2.import projects you want to upgrade into Eclipse workspace\n");
desriptors.append(" 3.click \"yes\" to show all the steps");
Boolean openNewLiferayProjectWizard = MessageDialog.openQuestion(UIUtil.getActiveShell(), "Show All Pages", desriptors.toString());
if (openNewLiferayProjectWizard) {
showAllPages();
}
}
};
mgr.add(restart);
mgr.add(showAllPages);
}
Aggregations