Excerpt and taxonomies on SULU Admin - sulu

how can I hide or disable "Excerpt and taxonomies" tab on SULU Admin UI, on my custom page template?

You can manipulate existing tabs by registering a custom Admin class and use the $viewCollection->get method to get the excerpt instance you could then hide it using a setTabCondition.
public function configureViews(ViewCollection $viewCollection): void
{
if ($viewCollection->has('sulu_page.page_edit_form.excerpt')) {
$viewCollection->get('sulu_page.page_edit_form.excerpt')
->setTabCondition(false);
}
}
Make sure the priority is lower then the original Admin Priority e.g.:
public function static getPriority(): int
{
return PageAdmin::getPriority() - 1;
}
Still I would not recommend hiding the excerpt tab as things like smart content which using the excerpt categories and tags.

Related

Type hierarchy missing members contributed by aspects

When I open the Quick Type Hierarchy popup (ctrl+t) on an interface method, it doesn't include any mention of implementation methods that are contributed by aspects. What can I do to make these show up?
For example, consider the following interface, classes and aspect:
Interface:
public interface Editable {
void save()
}
Class Implementing Editable#save directly:
public class EditableItem implements Editable {
public void save() {
// do some saving
}
}
Another class, this time without direct implementation of Editable's save:
public class EditableModule implements Editable {
// o-oh.. not implemented here
}
But this aspect adds save to EditableModule:
privileged aspect EditableModule_Editable {
public void EditableModule.save() {
// implemented over here..
}
}
With that in mind, in Eclipse, if you position your cursor on save in Editable and press ctrl+t, the Quick Type Hierarchy popup displays Editable at the root of the hierarchy tree and a single child EditableItem. I would expect to see EditableModule there as well.
Can post pom.xml if that would help.

MvvmCross navigation on screen

Our designer created a layout something like the screen above. The main idea was to create an application with only one screen, just the red part of the screen is changing (i.e. 2 textbox instead of 1 textbox) when you tap on a button. This application will be a multiplatform application and I'm using MvvmCross to create it. My question is that how can i achieve this behavior in Mvvm? My first thought was sg. like the code below, but I'm not satisfied with this solution. Do you have any better solution to this problem? Should i somehow overwrite default navigation on ShowViewModel()?
public class MainViewModel : MvxViewModel
{
private MvxViewModel _currentViewModel;
public MvxViewModel CurrentViewModel
{
get { return _currentViewModel; }
set { _currentViewModel = value; RaisePropertyChanged(() => CurrentViewModel); }
}
public MainViewModel()
{
CurrentViewModel = new DefaultViewModel();
}
public void OnButtonClick()
{
CurrentViewModel = new SecondViewModel();
}
}
public partial class MainViewModel : MvxViewController
{
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
FirstViewModel.WeakSubscribe(ViewModelPropertyChanged);
}
private void ViewModelPropertyChanged(object sender, PropertyChangedEventArgs args)
{
if (args.PropertyName == "CurrentViewModel")
{
if (Model.CurrentViewModel != null)
{
if (Model.CurrentViewModel is SecondViewModel)
{
//remove bindings
//change View
//bind new viewmodel
}
}
}
}
The alternatives for this kind of 'non-page navigation' are similar to those in MvvmCross Dialog:
You can:
Customize the MvxPresenter to allow ShowViewModel to be used
Put a special interface in the Core project and use Inversion of Control to inject the implementation from the UI project to the Core project
Use the MvxMessenger plugin and share messages between the Core and UI project which trigger this type of navigation.
Use a property with a special interface (like IInteractionRequest) on the ViewModel - that property will fire an event when the UI needs to change.
Personally, for your situation, I quite like the first of these options - intercepting ShowViewModel using a presenter.
One other alternative which I might consider is to use some kind of 'Adapter-driven' control which could very easily update it's child contents based on the CurrentViewModel property. On Android, this would be as easy as using an MvxLinearLayout with an adapter. On iOS, however, I think you'd have to write something new to do this - just because iOS doesn't really have a LinearLayout/StackPanel control.

MvvmCross: Android custom webview urls handlers

My Android application had some complex text with hyperlinks embedded inside. The easiest way for me to handle this was to just use an embedded WebView and detect hyperlink clicks to perform custom commands. I am trying to do this the MvvmCross way. Is there a binding available for WebView.SetBackgroundColor or WebView.LoadData? Once I get my custom html inside and the user clicks on hyperlinks, I have used WebView.SetWebViewClient to install my own client which can detect hyperlink clicks and perform custom actions. Any way to turn all of that into proper MvxCommand usage?
Is there a binding available for WebView.SetBackgroundColor
For View color binding see the sample: https://github.com/slodge/MvvmCross-Tutorials/tree/master/ValueConversion
or WebView.LoadData?
See Dynamic Binding UIWebView in MVVMCross
I have used WebView.SetWebViewClient to install my own client which can detect hyperlink clicks and perform custom actions. Any way to turn all of that into proper MvxCommand usage?
It's not clear to me what your question is. Maybe try coding something first and then coming back with some sample code for the problem - eg come back with a specific question about a specific ViewModel so that others can try to answer at a code level instead of at this more general level. Perhaps also try asking one question at a time and asking with a deeper level of detail - How to ask may help you get better results - see https://stackoverflow.com/questions/how-to-ask
I created a custom WebView by inheriting and added Command properties. I then added a custom WebViewClient to detect certain URL's and to call the corresponding command that was bound. Is this a good way to accomplish this?
public class AboutWebView : WebView
{
public IMvxCommand AboutCommand { get; set; }
public IMvxCommand LicenseCommand { get; set; }
public IMvxCommand PrivacyCommand { get; set; }
public AboutWebView (Context ctx,IAttributeSet aset) : base(ctx,aset)
{
SetWebViewClient (new AboutWebViewClient(this));
}
private class AboutWebViewClient : WebViewClient
{
private AboutWebView _parent = null;
public AboutWebViewClient(AboutWebView parent)
{
_parent = parent;
}
public override bool ShouldOverrideUrlLoading (WebView view, string url)
{
if (url.StartsWith ("about://"))
_parent.AboutCommand.Execute ();
else if (url.Equals (App.LICENSE_URL))
_parent.LicenseCommand.Execute ();
else
_parent.PrivacyCommand.Execute ();
return(true);
}
}
}

MvvmCross: How to navigate to something besides a ViewModel?

What would I put in my MvxCommand to navigate to a simple URL? All mobile platforms have a mechanism to ask the OS for an Activity or ViewController that can display the contents of a URL. How would I do that with MvvmCross? One way that I know of is to put special stuff in the presentationBundle and/or parameterBundle when calling ShowViewModel that the presenter can detect to do the special OpenUrl command. But is that the best way??
There is a plugin which enables this - https://github.com/slodge/MvvmCross/tree/v3/Plugins/Cirrious/WebBrowser
If that plugins is loaded, then a viewmodel can use:
public class MyViewModel : MvxViewModel
{
private readonly IMvxWebBrowserTask _webBrowser;
public MyViewModel(IMvxWebBrowserTask webBrowser)
{
_webBrowser = webBrowse;
}
public ICommand ShowWebPage
{
get { return new MvxCommand(() => _webBrowser.ShowWebPage("https://github.com/slodge/mvvmcross");
}
}
You can see this used in, for example:
https://github.com/slodge/MvvmCross-Tutorials/blob/master/Sample%20-%20CirriousConference/Cirrious.Conference.Core/ViewModels/BaseViewModel.cs
https://github.com/slodge/MvvmCross-Tutorials/blob/master/Sample%20-%20CustomerManagement/CustomerManagement/CustomerManagement/ViewModels/DetailsCustomerViewModel.cs
If you ever need to create your own plugins, see https://speakerdeck.com/cirrious/plugins-in-mvvmcross

How to handle property sheet from customized editor in eclipse plugin development?

I have to bind my editor widget objects in property sheet.So that i can the property of my widget from property view.
Please help me on this, if possible provide me some code snippets.
You have a good example in the Getting started with Properties
Using the Properties view is simple enough.
Since it shows properties for the selected object, the first step to using it is to make sure that the workbench selection service knows about the object selected in your view. There’s an entire Eclipse Corner article written on the subject of the selection service
public void createPartControl(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
getSite().setSelectionProvider(viewer);
viewer.setInput(getViewSite());
}
Once you have your view contributing to the workbench selection, you need to make sure that the objects that your view is selecting contribute properties
(extract)
public class Person implements IPropertySource {
private String name;
private Object street;
private Object city;
public Person(String name) {
this.name = name;
this.street = "";
this.city = "";
}
public Object getEditableValue() {
return this;
}
public IPropertyDescriptor[] getPropertyDescriptors() {
return new IPropertyDescriptor[] {
new TextPropertyDescriptor("name", "Name"),
new TextPropertyDescriptor("street", "Street"),
new TextPropertyDescriptor("city", "City")
};
}
I indicated earlier that this solution is “not necessarily [the] most correct”. This is because, for this to work, my domain object needs to know about the very view-centric (and Eclipse-centric) notion of being a property source; in short, there is a tight-coupling between the model and view and this not a good thing™.
Using adapter is a better approach, as described in this article:
Person should implement IAdaptable.
See also this recent article on how to create a custom property view
how to hack the Properties View to listen only to a specific view.
The isImportant() method is the one which decides whether to create an IPage for the specific IWorkbenchPart or not.
The idea is to override that method and return false for all the workbenchPart that we are not interested in. Lets create the view first:
<view
class="com.eclipse_tips.views.CustomPropertiesView"
icon="icons/sample.gif"
id="com.eclipse-tips.views.customePropertiesView"
name="My Properties View">
</view>
The CustomPropertiesView should extend PropertySheet and override the isImportant():
public class CustomPropertiesView extends PropertySheet {
#Override
protected boolean isImportant(IWorkbenchPart part) {
if (part.getSite().getId().equals(IPageLayout.ID_PROJECT_EXPLORER))
return true;
return false;
}
}
In this case, I'm making the view only to respond to Project Explorer and ignore other views
According to this thread, the same principle should be valid for an Editor instead of a View.
The property sheet listens to the workbench page selection provider.
The selection provider depends on what viewer/editor is active.
Each editor/viewer provides their own selection provider to use when that editor/viewer is active.
This way the property sheet doesn't care who is active, it just listens to the selection provider.
That way depending upon the view, a different set of properties are displayed.
For example, the Navigator view provides IResource selections, so the property sheet then displays IResource properties when the Navigator is active.
The Workbench Selection mechanism is illustrated in this article
The ISelectionListener is a simple interface with just one method.
A typical implementation looks like this:
private ISelectionListener mylistener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
if (sourcepart != MyView.this && // 1
selection instanceof IStructuredSelection) { // 2
doSomething(((IStructuredSelection) selection).toList()); // 3
}
}
};
Depending on your requirements your listener implementation probably needs to deal with the following issues as shown in the code snippet above:
In case we also provide selections (e.g. a view or editor) we should exclude our own selection events from processing. This avoids unexpected results when the user selects elements within our part (1).
Check whether we can handle this kind of selection (2).
Get the selected content from the selection and process it (3).