check if save button is clicked in eclipse plugin development - eclipse-plugin

Im trying to add decorators (eg. adding a suffix to a file) Whenever a save button click happens within a file that is currently open, I search but is having a hard time figuring it out Heres my code
public void decorate(Object resource, IDecoration decoration) {
if () //I'm having trouble with this check
{
decoration.addSuffix("--Modified");
}
}
Help would be appreciated

There is an IEditorPartListener that listens to if editor is "dirty" meaning unsaved or not dirty meaning saved you need to get a reference to the IEditorPart and add the correct listener than you can decorate you navigator as you please.

Related

How to get the user's new page selection in a Notebook control under Windows?

In my app, when a user has made changes to the data on one page of my notebook control, I want to prompt them to save or discard their changes when they switch to a different page. I have bound the EVT_BOOKCTRL_PAGE_CHANGING event for this, and have created a handler method.
However, I can't tell what page the user is switching to. According to the wxBookCtrlEvent docs,
under Windows, GetSelection() will return the same value as GetOldSelection() when called from the EVT_BOOKCTRL_PAGE_CHANGING handler and not the page which is going to be selected.
Is there a workaround?
I guess as a workaround, you could use a mouse handler checking for when the left button is clicked. In a handler for that event you could do a hit test to see where the click was made and store the value of the tab that was clicked. Something like this:
void MyFrame::OnLeftDown( wxMouseEvent& event )
{
long flags;
int ht = m_notebook1->HitTest( wxPoint(event.GetX(),event.GetY()), &flags);
if( (flags & wxBK_HITTEST_NOWHERE) == 0 )
{
//store the value of ht somewhere
}
event.Skip();
}
void MyFrame::OnNotebookPageChanging( wxNotebookEvent& event )
{
//use the stored value of ht here
}
under Windows, GetSelection() will return the same value as
GetOldSelection() when called from the EVT_BOOKCTRL_PAGE_CHANGING
handler and not the page which is going to be selected.
So, call GetSelection from EVT_BOOKCTRL_PAGE_CHANGED to get the new page.
No, there is no workaround (if there were a reliable way to do it, wxWidgets would have been already doing it), the underlying native control simply doesn't provide this information.
You can either ask whatever you need to ask the user about in any case, independently of the page they're switching to, or ask them after they will have already switched -- which is, of course, going to look weird if you then decide to switch back.
If you really, really need this functionality, you might use non-native wxAuiNotebook instead.

How does Opencart Module saves its settings?

Hey guys I ran into a bit of a problem with module I am developing for OpenCart v1.5.6.4. This is what I have in Admin section for module settings.
As you can see I built in extra tabs where I want to give user the ability to specify extra options which will be used to build out a prescription form on the Catalog side.
Problem is how do I go about Save extra data from each additional tab to a custom table when user click on Save button?
Is there a special function that gets called when Save button is clicked that I could implement myself?
Eh, I guess I was a bit tired last night to realise that this section of code defined in index() handles saving of module setting to the database:
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
//save module settings
$this->model_setting_setting->editSetting('prescripts', $this->request->post);
//mark of success
$this->session->data['success'] = $this->language->get('text_success');
//redirect back to module page
$this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
}
So all i need to do is stuff my custom code in here and I am done with Admin controller.

Sugarcrm : modify actions on Dashlet quickEdit button

I have a very specific question on Sugarcrm.
I'm using version Enterprise 6.5.16, and i'm coming to a dead-end.
What i currently have :
When the user is on his homepage, he has a Dashlet called "My open Cases", which displays every open Cases assigned to/or created by him.
For each row of this dashlet, we have a quickEdit icon displayed. (you know, the little pen).
When the user clicks on that little icon, it opens the quickcreate (or quickedit?) popup.
What i want to achieve is :
I want, when the user clicks on the icon, that Sugar does not open a popup, but opens a new browser tab on EditView.
So basically, when on Home, when the user wants to edit "Case01--Issue" from the dashlet, instead of poping the quickcreate (or quickedit) form, i want to open a new browser tab with the complete edit view of "Case01 -- Issue".
What do i have to do? I did not see the definition of the icon in custom/modules/Cases/metadata/dashletviewdefs.php nor elsewhere.
Thanks by advance for your help and time!
Gaƫlle
The "My Cases" dashlet, and most dashlets, extend the DashletGeneric class, found in /include/Dashlets/DashletGeneric.php. This uses the template file DashletGenericDisplay.tpl in the same directory, and this is the template that displays the quick edit button.
To remove or alter the quick edit button, you would extend My Cases and insist that it use a custom smarty template of your own creation. In /custom/modules/Cases/Dashlets/CustomMyCasesDashlet/CustomMyCasesDashlet.php you might have the following:
<?php
require_once('modules/Cases/Dashlets/MyCasesDashlet/MyCasesDashlet.php');
class CustomMyCasesDashlet extends MyCasesDashlet{
$displayTpl = 'custom/modules/Cases/Dashlets/CustomMyCasesDashlet/CustomMyCasesDashlet.tpl';
}
You would then copy the original template to the new file and location referenced by CustomMyCasesDashlet::displayTpl and adjust as desired.
For your Dashlet to register correctly with the system, you'll also need your CustomMyCasesDashlet.meta.php file. Copy the original to your custom directory and adjust labels as necessary -- the key is to replace references to MyCasesDashlet with CustomMyCasesDashlet.
You should create your own dashlet (with copying existing one in "custom" folder), replace all standart entries to your own. Add copy of DashletGenericDisplay.tpl too and name it like CustomMyCasesDashlet.tpl.
It's not necessary to extend MyCasesDashlet class. You can leave "extends DashletGeneric".
In constructor function CustomMyCasesDashlet() just add the line:
$this->displayTpl = 'custom/modules/Cases/Dashlets/CustomMyCasesDashlet/CustomMyCasesDashlet.tpl';
Pay attention to $this->. Its necessary to override DashletGeneric field.
Copy the file from modules/Cases/Dashlets/MyCasesDashlet/MyCasesDashlet.php and paste it to custom/modules/Cases/Dashlets/MyCasesDashlet/MyCasesDashlet
If you don't have Cases folder inside the custom directory, create one.
After copying the file, add a property to load your custom TPL file.
Default DashletGenericDisplay.tpl file located at include/Dashlets/
class MyCasesDashlet extends DashletGeneric {
var $displayTpl = "custom/modules/Cases/Dashlets/DashletGenericDisplay.tpl";

BlackBerry 10 Cascades app stuck affecting property

I have an issue with a list/detail pattern. I have an Article class, inheriting from QObject, defining some properties (title, updated and content being the ones that matters for now). To populate my (QML) ListView, I have a C++ GroupDataModel, filled with some Article*. Here's my list's onTriggered:
onTriggered: {
if (indexPath.length > 1) {
currentArticle = dataModel.data(indexPath);
var page = articlePageDefinition.createObject();
nav.push(page)
}
}
As you can guess, the articlePageDefinition defines a page using the upper currentArticle property.
Now, when I display the articlePage once, it's working fine. I can go back, click on the same list item, display the same Article details, works great. But when I pick a second article, the app kind of freezes. I can go back in my navigation pane, but I can't click on list items anymore. I tried to add some logs, the onTriggered is stuck on currentArticle = dataModel.data(indexPath);. At this point, I can log every property of dataModel.data(indexPath) without any issue. I tried to not create/push the page, simply affect currentArticle and display some of its properties, it's working fine too. I really don't understand what I am doing wrong here, any help appreciated.
In case you need to see more code, everything is here: https://github.com/Kernald/tt-rss-bb10/tree/e29e3b616aa179dd42f66804ecc20a6a45b6bb22
Here what can cause the problem your are having:
You create the articlePage and bind it's data to the "currentArticle" global variable
When you go back the articlePage is not deleted.
You open an other instance of this same articlePage. The last one still bind its data to the same currentArticle instance.
When you go back and click another item: the previous articlePage still exists in memory. It binds to "currentArticle". The problem is, it's not the data of "currentArticle" that has changed but the object referenced by "currentArticle". The Qml binder just fails then.
I had a similar behavior of my app, but I did not inspect your github code if the reason can be the same. I think you can verify that more quickly than me.
When removing and adding a list item with the same index, the code gets stucked. I removed an entry on user action and added a new one at that place, and it got stuck. This is a known issue to BB10, I found here: https://developer.blackberry.com/cascades/download/releasenotes/#known

End conversation when leave page in Seam

I have a wizard in my Seam project which has four pages. When user starts the wizard by coming to the first page (wizard1.xhtml) I start a conversation. To do that in my pages.xml I have following code.
<page view-id="/pages/wizard1.xhtml">
<begin-conversation join="true"/>
</page>
At the final page of the wizard (wizard4.xhtml) I have a save button and I end the conversation by using #End annotation.
#End
public String save() {}
However while moving through the wizard, the user can redirect to a page outside the wizard by clicking a link. Note that if this happens the conversation is not yet ended.
What I want is to immediately end the conversation as soon as the user is no longer on a wizard page (wizard1.xhtml,wizard2.xhtml,wizard3.xhtml or wizard4.xhtml). I found this post but a timeout is not a good choise in my case since I want to end the conversation immediately.
I think the most straight forward and natural solution of your problem is to make your click-able link like this:
<s:link value="here is the link" view="/expectedView.xhtml"
action ="#{targetBean.endingConversation()}"/>
And your endingConversation() method can be like this:
#End
public void endingConversation(){
//do cleanup code
}
The idea is simple, you should employ a guard in every possible exiting points.
Not sure if it will work, just a thought.
Create some javascript function using a4j:jsFunction that calls a method that's annotated with #End.
You then add this jsFunction as an onClick handler to all Your links. (Not sure if onClick is the best handler though).
When the user navigates away from Your wizard the method is called and the conversation should be ended.
If you are using pages.xml (or the per-page page.xml files) to implement page navigation in your application, then you have to specify redirect behavior, for each page, based on the action string. In the navigation rule for each redirect that is not continuing your wizard conversation, you can add <end-conversation />. This is similar to other suggestions, but the result would be navigation rules files which illustrate your applications page flow including the demarcation of your long-running conversations.