How to remove non-existing printers from print service on android? - android-service

I'm developing a print service on android. The list of available printers changes quite often. However, I have not been able to find a way of removing the non-existing printers (i.e. printers that were available at some point). These printers appear grayed-out on my test devices.
I can see 'zombie' printers in PrinterDiscoverySession's onStartPrinterDiscovery() and onValidatePrinters() methods but do not know how to get rid of them. Calling session's addPrinters() with existing printers or removePrinters() with non-existing ones does not help.
I'd appreciate any suggestions.
Thanks.

From the android default print service print menu:
Select the down arrow in the available printer list.
Select "All Printers".
Select "Add Printer".
Select "Default Print Service".
You will see "Saved Printers"
Select the printer that you would like to remove from the list.
Select "Forget"
Back space out to the available printers list.

PrinterDiscoverySession.GetPrinters() this will give you a list List<PrinterInfo> with PrinterInfo. You can search the list of Printers for where STATUS_UNAVAILABLE is not 0
Check out these for probably a clearer answer:
PrinterDiscoverySession()
https://developer.android.com/reference/android/printservice/PrinterDiscoverySession
GetPrinters()
https://developer.android.com/reference/android/printservice/PrinterDiscoverySession#getPrinters()
PrinterInfo
https://developer.android.com/reference/android/print/PrinterInfo
STATUS_UNAVAILABLE ("Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR")
https://developer.android.com/reference/android/print/PrinterInfo#STATUS_UNAVAILABLE
Another option may be
Another way is to use PrinterInfo.GetStatus()
https://developer.android.com/reference/android/print/PrinterInfo#getStatus()

Related

Special characters in drop-down list with Robot Framework (Selenium)

just wondering if any of you know how to handle special characters with a website that contains a drop-down list. I scripted the following in Robot Framework (Selenium) to verify the contents of a drop-down list:
Verify all required fields and labels are present
Verify a and lists of b for 'ööö'
Verify a and lists of b for '${xyz}'
(...)
Dropdown "{abc}" should contain options "${json_blabla["ABC"]["${xyz}"]}"
However, when trying to do that, I get the following error message when running the script:
Resolving variable '${json_blabla["ABC"]["ööö"]}' failed: KeyError: '\xc3\xb6\xc3\xb6\xc3\xb6'
Any idea how to get around this? I'm sure I saved everything in UTF-8 encoding, and I think the JSON file should be fine too, so I'm suspecting it's somewhere in the script I just showed?
Found it:
It seems that it needs to be told explicitly that the string must be in Unicode, so one option to have it corrected is:
Dropdown "{abc}" should contain options "${json_blabla["ABC"][u"${xyz}"]}"
And voilà!
Thanks for voting & until next time!

Netsuite Advanced PDF BOM

I am creating a print out for BOM using advanced pdf. I am trying to get get the value of the Start Date from the work order but in the print out, it is empty. I set this using ${record.startdate}. Is this correct? Is there another internal id for start date and end date in the work order?
Thanks!
If the object passed to the pdf generator name is "record" offcourse you can reference is as it is. It depends on the passed parameter name. If you are modifying existing html check the rest of the script and you will see if its 'record' or not.
You can reference with ${record.startDate} and ${record.endDate}
All the available fields for the object can be found here.

Dialog box appear

I'm using decode for my query but when every time I run my query, there's a two dialog box appeared and need to input some number in those dialog box before to see the result. What should I need to remove it?
Please help me.
Thank you.
Here's some of my query..
SELECT (CODE_SALESROOM) POS_ID
,DECODE(CODE_SALESROOM, '60001', 'ABM SYSTEM'
,'50001', 'Acenet Unlimited Business Computer'
,'40002', 'RL My Phone - Robinsons Galleria') AS POS_NAME
FROM OWNER_DWH.DC_SALESROOM
WHERE CODE_SALESROOM NOT IN ('XAP', 'XNA', '10001')
Sounds like you're being prompted for substitution variables, because part of your query has somethling like and col = 'AT&T' - the ampersand is interpreted as a variable by default, and you're prompted for a value for &T (or whataver your actual value is interpreted as).
You can add set define off to your script to stop it looking for, and prompting for, a value when that is not what you want.
(The links are for SQL*Plus documentation, but much of that applies to SQL Developer as well; the documentation for that is a bit sparser),

Formatting output so that Intellij Idea shows diffs for two texts

I would like to be able to print in the logs a message for which intellij idea would present a nice way of comparing two objects (strings). This happens automatically for the error message logged by a failed junit assert:
assertEquals("some\nString", "another\nString");
=>
org.junit.ComparisonFailure: <Click to see difference>
at org.junit.Assert.assertEquals(Assert.java:123)
at org.junit.Assert.assertEquals(Assert.java:145)
at com.something.DummyTest.testDummy(DummyTest.java:89)
The <Click to see difference> entry is actually displayed as a link in the output window of the Intellij Idea. When you click on the link, a compare window opens which shows the two values (just like you would compare two files).
Simply throwing an exception is not acceptable because I would like to log multiple objects to compare. I already tried logging a text, but I wasn't able to convince idea to compare the two texts.
IntelliJ IDEA is using the hardcoded regular expression. If the text matches the pattern, it will suggest to click to view the difference.
The pattern is:
expected:<bla-blah> but was:<blah-blah-blah>
Output should match the format of assertEquals or assertThat.
The exact patterns are somewhat scattered around the code in IDEA, but some are e.g. here.
I had the same Problem and found the solution in https://github.com/joel-costigliola/assertj-core/issues/1364#issuecomment-440800958
You should throw an org.junit.ComparisonFailure. Then IntelliJ will display the <Click to see difference>

Eclipse RCP: How to order perspective buttons belonging to different plugins?

My application has 5 plugins. Each plugin has a perspective of it's own and hence each perspective extension definition is under individual plugin's plugin.xml.
Now, I want to control the order in which these perspectives appear in my application. How to do it?
There is one main plugin that holds "ApplicationWorkBenchAdvisor.java". This has initialize() method in which I am iterating through the perspective registry using
PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
and then appending perspective ids in a comma separated fashion to a String variable (pbar) which is used later like this.
PlatformUI.getPreferenceStore().setDefault(IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS, pbar);
PlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS, pbar);
When iterating thourgh the perspective registry, I can compare perspective ids and sort it(when adding to 'pbar' by comparing ids) the way I want it to appear but, I don't want to do this ordering here as it appears like a dirty way.
Is there any other place where we can fix the order in which perspectives appear? (Each perspective resides in different plugin).
ADDED
1) Could we also control the ordering in the perspective switcher?
2) Is there a way to control entry into perspective registry to in inflict the desired order. If not could we write back into perspective registry?
If your application is encapsulated as an eclipse product, you may tweak the plugin.properties/plugin_customization.ini file.
(file referenced by the 'preferenceCustomization' property in your product extension point.)
This file is a java.io.Properties format file. Typically this file is used to set the values for preferences that are published as part of a plug-in's public API.
(Example of such a file for org.eclipse.platform)
So if the string representing the order of perspective can be referenced as a property, you can define the default order in there.
Since the source code of IWorkbenchPreferenceConstants mentions:
/**
* Lists the extra perspectives to show in the perspective bar.
* The value is a comma-separated list of perspective ids.
* The default is the empty string.
*
* #since 3.2
*/
public static final String JavaDoc PERSPECTIVE_BAR_EXTRAS = "PERSPECTIVE_BAR_EXTRAS"; //$NON-NLS-1$
Maybe a line in the plugin_customization.ini file:
org.eclipse.ui/PERSPECTIVE_BAR_EXTRAS=perspectiveId1,perspectiveId2,perspectiveId3
would allow you to specify that order without having to hard-code it.
Additional notes:
IPerspectiveRegistry (or PerspectiveRegistry) is not made to write anything (especially for perspective defined in an extension)
Ordering may be found in the state of the workbench (stored in the workspace and then restored when its launched again, .metadata/.plugins/org.eclipse.ui.workbench/workbench.xml)
Do you confirm that:
IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor[] perspectives = registry.getPerspectives();
is not in the right order when the plugin_customization.ini does define that order correctly ?
Liverpool 5 - 0 Aston Villa does confirm that (in the comments), but also indicates the (ordered) ini file entries internally get recorded into preference store, which means they can be retrieved through the preference store API:
PatformUI.getPreferenceStore().getDefault(
IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS)
Liverpool 5 - 0 Aston Villa then add:
perspective registry (the initial "PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();" bit) remains unaltered (and unordered).
But, you still can "readily access to ordered list of perspectives" through preference store.
So, for other tasks, instead of iterating though perspective registry (which is still unordered), we can use the ordered variable that stores list of ordered perpective ids.
.
.
.
.
Note: another possibility is to Replace the Perspective-Switcher in RCP apps
=> to:
You can more easily define the order in a menu or in buttons there.
Extreme solution: re-implement a perspective switcher.
To sum up all the observations and findings,
1) It is not possible to alter entries in the perspective registry. It is read-only.
2) To make perspective appear in the order that we want on perspective bar, we can achieve it by adding an entry in plugin_customization.ini (or preferences.ini) as shown below.
org.eclipse.ui/PERSPECTIVE_BAR_EXTRAS=perspectiveId1,perspectiveId2,perspectiveId3
3) If we want to fetch this ordered list, we can't fetch it directly. But as this ini file entry internally gets recorded in PreferenceStore we can fetch the same value from PreferenceStore using the following API as shown below.
PlatformUI.getPreferenceStore().getDefault(
IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS);
Why would someone need to access the entry defined in ini file at all?
Well, in my case I had a view in which i had to display links to every perspective. As my perspective bar was sorted in desired order, I also wanted to maintain the same order in my view while displaying links to perspectives.
4) There is no known way to inflict the same sort order in the display of default perspective switcher. While a new custom perspective switcher can be written to achieve the desired effect.