Anyone have any idea how TabStop works in iText 5.5.0 - itext

I'm still trying to learn iText and have a few of the concepts down. However I can't figure out what TabStop is or how to use it. My particular problem is that I want to fill the end of all paragraphs with a bunch of dashes. I believe this is called a TabStop and I see the class in the itext jar but I have no clue on how to use it. I must be searching the wrong thing on google, but I've come up with nothing. The iText in Action book also doesnt seem to even know of the existance of this class so any help is much appreciated!

Please take a look at the ChunkTest class in iText's test suite. It contains several use cases of the tab stop functionality. For instance:
java.util.List<TabStop> tabStopsList = new ArrayList<TabStop>();
tabStopsList.add(new TabStop(100, new DottedLineSeparator()));
tabStopsList.add(new TabStop(200, new LineSeparator(), TabStop.Alignment.CENTER));
tabStopsList.add(new TabStop(300, new DottedLineSeparator(), TabStop.Alignment.RIGHT));
p = new Paragraph(new Chunk("Hello world", f));
p.setTabSettings(new TabSettings(tabStopsList, 50));
addTabs(p, f, 0, "la|la");
ct.addElement(p);
The TabStop functionality was introduced after the iText in Action books were written. They'll be documented in one of the new books.
For another example, see http://developers.itextpdf.com/examples/itext-building-blocks/tabbing-examples

Related

How to trigger a function when a custom field is edited/created in redmine

I have been researching about this term for so many hours, but I found anything useful yet.
Hope you can help us building this redmine plugin, or provide us some research links to help us find the correct key.
What we want to build
The thing is we want to update one custom field in redmine (let's name it 'Target_CF') whenever another one is created or updated.
We are looking for incrementing possible values of Target_CF, so we can have all custom field's names available to select.
Of course, we want to achieve this without directly editing Redmine's Core, so we thought developing a plugin would be the best approach.
Our plugin also creates and configures a new custom field (the one mentioned above), but I will let this out of the question, because I think it is not relevant for this.
Where we are right now
We have identified some hooks that could be useful for us, as the following:
:controller_custom_fields_new_after_save
:controller_custom_fields_edit_after_save
We have the following directories/files structure so far:
plugins/
custom_plugin/
init.rb
lib/
hooks.rb
The code we have written
init.rb
require_dependency 'hooks'
Redmine::Plugin.register :custom_plugin do
name 'custom_plugin'
author 'author name'
description 'description text'
version '1.0.0'
end
hooks.rb
class Hooks < Redmine::Hook::ViewListener
def controller_custom_fields_edit_after_save(context={ })
#target_custom_field_name = "Target_CF"
CustomField.find_by_name(#target_custom_field_name).possible_values.push(context[:custom_field].name)
end
end
The result of this code is none. I mean, no erros, no updates, nothing at all. There is no change in our possible values after editing/creating another custom field. We are sure there is something we don't know, some concept or workflow, and due to this we are doing something so badly.
Please, help us understeand what we are missing.
Previously we have succesfully developed another plugin that overwrites certain views. So we have kind of little skills in views related plugins, but zero experience at all at controllers ones.
We are using a Redmine 3.2.0 stack by Bitnami and a mysql database.
Well, finally we found out how to extend base controller's methods. I will post it here so hopefully this can be useful to anyone who finds the same doubts we had.
After some more researching, we conclude that it is mandatory to extend base controllers, in order to not directly modify core methods.
This is our final directories/files structures:
plugins/
custom_plugin/
init.rb
lib/
custom_plugin/
issue_custom_field_patch.rb
We previously stated that we could use some hooks to inject our desired functionality, but it seems not to work that way with controllers. On the other hand, we built a patch which will extend target class functionality.
Our final working code
Init.rb
require 'redmine'
ActionDispatch::Callbacks.to_prepare do
require_dependency 'issue_custom_field'
unless IssueCustomField.included_modules.include? CustomPlugin::IssueCustomFieldPatch
IssueCustomField.send(:include, CustomPlugin::IssueCustomFieldPatch)
end
end
Redmine::Plugin.register :custom_plugin do
name 'custom_plugin'
author 'author name'
description 'description text'
version '1.0.0'
end
issue_custom_field_patch.rb
module CustomPlugin
module IssueCustomFieldPatch
def self.included(base) # :nodoc:
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
after_save :update_possible_values
end
end
end
module ClassMethods
end
module InstanceMethods
def update_possible_values
self.reload
updatedPossibleValues unless self.name == "Target_CF"
end
private
def updatedPossibleValues
#safe_attrs = ['project', 'description', 'due_date', 'category', 'status', 'assigned_to', 'priority', 'fixed_version', 'author', 'lock_version', 'created_on', 'updated_on', 'start_date', 'done_ratio', 'estimated_hours', 'is_private', 'closed_on']
#custom_fields = IssueCustomField.all.select {|cf| !cf[:position].nil?}.collect {|cf| cf.name}
#possible_values = #safe_attrs + #custom_fields
CustomField.find_by_name("Target_CF").update possible_values: #possible_values
end
end
CustomField.send(:include, IssueCustomFieldPatch)
end
Functionality explained
As we stated in the question, we needed to update Target_CF possible values each time the users create/modify/removes a custom field from Redmine.
We extended IssueCustomField's class's instance methods, triggering our new function 'updatedPossibleValues' after each save. This includes creating new custom fields, and of course, updating existing ones and removing them. Because we reload our list of possible values each time, we had to control if its position were nil. If it is, this means that custom field has been removed.
Because of the ultimate action of this patch, which is the updating of another custom field, this also triggered our function, causing an infinite loop. To prevent this, we linked our functionality to every other custom field which name was not 'Target_CF'. A bit rusty fix, but we couldn't find a better approach.
I hope this can be useful to somebody in the future, as they could invest a fraction of time that we spent on this.
Comments, fixes and improvements are very welcome.
Based on: https://www.redmine.org/projects/redmine/wiki/Plugin_Internals which is a bit outdated, but finally could complete the code with help of another resources and forums.

Protractor Implementation in Angular2 without using ids

I have application in Angularjs2, and developers have not been using ids into it. Now I have to implement the Protractor on same application. Is there anyway to implement the Protractor without using "absolute XPath"?
Thanks in advance!
Please find a huge range of locator-possibilities on the official Protractortest API Page
Every element on a page needs to be uniquely identifiable... else the page wouldn't work, no matter which technology. Therefore with the help of any of the above provided locator-possibilities you'll always find the element you're looking for.
And there is never a need for XPath, except for this only one. (though there is an parentElementArrayFinder introduced in the meantime, so not even that one exception is valid anymore)
UDPATE
If you could use XPath, you can for sure use CSS-Locators.
Here some examples for locators:
$('div.class#id[anyAttribute="anyValue"] div.child.somewhere-below-div-point-class')
element(by.cssContainingText('div[data-index="2"]', 'select this option'))
Or as a specific example the "Learn More" of the "Tree List" section of https://js.devexpress.com/ :
treeListSection = element(by.cssContainingText('div.tab-content h2', 'Tree List')).getDriver();
learnMoreBtn = treeListSection.element(by.cssContainingText('a.tab-button','Learn More'));
learnMoreBtn.click();
Those are just examples, but there is always a way to do it.
If you provide some example-HTML in your Question, I can direct you towards a solution.
UPDATE 2
For getting the Parent Web Element, one could use getDriver() as well

Unicode and PDF tooltips / messageboxes with iTextSharp

I need to find a way to add a quite long string in a quite small space in a PDF document.
I am using iTextSharp. I have already tried adding comment annotations (balloons) with PdfAnnotation.CreateText() and I didn't like the way they looked/worked. It made the page too heavy (I had many comments per page) and their behavior was odd in many ways (thank Adobe for that).
Now I was thinking of adding some simple tooltips on 'chunks' in the page or popping-up messageboxes with javascript (like illustrated here : http://www.codehacker.com/ITEXTSHARP/chap15.aspx#). To my great disappointment however, it seems that Acrobat (?) doesn't support Unicode characters in those situations. E.g. I do this:
var javascript = new PdfAnnotation(
w, 200f, 550f, 300f, 650f,
PdfAction.JavaScript("app.alert('" + "Αρνάκι άσπρο και παχύ!" + "');\r", w));
chunk.SetAnnotation(javascript);
...and, in the best case, a messagebox with gibberish pops up when the user clicks on the chunk.
Is there any setting for making Unicode acceptable for the code above or another way to do what I want?
EDIT:
I have now seen this: https://stackoverflow.com/a/163065/964053
and I've tried modifying my code like that:
var javascript = new PdfAnnotation(
w, 200f, 550f, 300f, 650f,
PdfAction.JavaScript((char)0xFEFF + "app.alert('" + "Αρνάκι άσπρο και παχύ!" + "');\r", w));
chunk.SetAnnotation(javascript);
But nothing seems to change...
EDIT2 :
Using octal representation e.g. (\141) doesn't seem to help either...
EDIT3 :
This seems to work nice until you double clink on it, but I need to make the tooltip size itself based on the contents size:
var lToolTip = PdfFormField.CreatePopup(
w, new Rectangle(tc.Left, tc.Bottom, tc.Right, tc.Top), val, true);
chunk.SetAnnotation(lToolTip);
The rectangle provided doesn't seem to be used in any way...
Any ideas?
I don't know what PdfFormField.CreatePopup() is supposed to create, but I see a small mark on my page that displays a popup when you hover the mouse over it.
I'm kind of lost in your edits, it's not clear what works for you and what doesn't, but regarding the unicode problem in JavaScript: are you aware that there are two versions of the javaScript() method?
See javaScript(java.lang.String, com.itextpdf.text.pdf.PdfWriter, boolean)
If you add the boolean value true, the JavaScript string should be interpreted as Unicode. If this doesn't solve your problem, I'll delete this answer, and if you clarify your question (cutting away the irrelevant parts), I'll do another attempt.

Using pyUno to write text into Libre/OpenOffice Writer

I am trying to export some text from Python into a Libre/OpenOffice Writer document which I created according to these instructions.
For example, using
cursor.setPropertyValue("CharHeight", 20)
cursor.setPropertyValue("CharWeight", 150)
document.Text.insertString(cursor, "This Is Heading One", 0)
I can make a line of text look like a heading, but it's just text and not an actual heading. What property values do I have to modify to generate a heading line that's picked up for the TOC?
In general, where is the documentation for the properties, and how to navigate the Writer document in general? I'm having a very hard time digging up anything at all!
I guess this hasn't attracted much interest on stackoverflow :) Neither has it in the forum over at LibreOffice.
Fortunately, the folks over at OpenOffice had a few good pointers, and a thread with above questions and more is here. I'm going to keep discussing various aspects of document creation over there.

Updating Jira Plugin from Version 3 to Version 4, Replacing SearchParameter

i am pretty new to Jira Development so please be patient
I should upgrade a Plugin that worked with Jira Version 3 to work with Jira Version 4
Most of the thins went pretty well, but now i am kind of stuck
The SearchParameter and the ProjectParameter Class are not available in the new Version and i dont exacly know how to replace them. its really just this few lines of code, where its needed
these Classes are outdated: SearchParameter and ProjectParameter
i looked in the jira doc buts its seems pretty complicated, you would do me a great favor if you could help me
SearchRequest sr = srs.getFilter(ctx, filterId);
...
SearchParameter param = sr.getParam(new ProjectParameter().getName());
...
List columns = columnLayout
.getVisibleColumnLayoutItems(user,
param.getValues(), Collections.EMPTY_LIST);
It would even Help if you could explain what the seccond Line intends
Thanks in advance
I can't help you rewrite the plugin entirely, but I can try help you decipher what those quoted lines of code mean:
SearchRequest sr = srs.getFilter(ctx, filterId);
This line loads a saved SearchRequest with the corresponding filterId.
SearchParameter param = sr.getParam(new ProjectParameter().getName());
This line gets the Project search parameter that was saved in the SearchRequest. As you may know, SearchRequests (or saved filters if you prefer) all you to save a search from JIRA with parameters defined. One possible parameter to define is a ProjectParameter. So if your search is "all issues in project X", then you would have a SearchParameter in your SearchRequest which is a ProjectParameter that knows to search for project X.
List columns = columnLayout
.getVisibleColumnLayoutItems(user,
param.getValues(), Collections.EMPTY_LIST);
This line retrieves the ColumnLayoutItems which are visible to the specified user, for the specified projects of the SearchRequest (by extracting the value from the ProjectParameter of the SearchRequest as retrieved in line 2).
It's a bit unclear what this code is attempting to do without more context, but that's what those lines are doing anyway. You might find the API documentation useful:
http://docs.atlassian.com/jira/3.13/
http://docs.atlassian.com/jira/3.13/com/atlassian/jira/issue/fields/layout/column/ColumnLayout.html