Search Results

Search found 13 results on 1 pages for 'laimoncijus'.

Page 1/1 | 1 

  • Nagios service active only when other service is failing

    - by Laimoncijus
    Is is possible to define service to be active only the times while other service is failing? Consider following example: 2 hosts available: HostA (primary) and HostB (backup). Nagios service, which monitors amount of active connections to the host: gives OK when amount of connections to host 0 gives FAILURE when amount of connections to host = 0 If setup nagios service to monitor both hosts: HostA and HostB - it will give me OK for HostA (while it is primary and all connections normally goes to it) and FAIL for HostB (while it is backup and will receive no connections while HostA is alive). Can I make the nagios service for HostB somehow depend on sevice of HostA and give no failures (or maybe be inactive) up to the moment the service of HostA starts failing?

    Read the article

  • SWT: problems with clicking button after using setEnabled() on Linux

    - by Laimoncijus
    Hi, I have a strange case with SWT and Button after using setEnabled() - seems if I disable and enable button at least once - I cannot properly click with mouse on it anymore... Already minify code to very basic: import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class TestButton { public TestButton() { Display display = new Display(); Shell shell = new Shell(display); GridLayout mainLayout = new GridLayout(); shell.setLayout(mainLayout); shell.setSize(100, 100); Button testButton = new Button(shell, SWT.PUSH); testButton.addSelectionListener(new TestClickListener()); testButton.setText("Click me!"); //testButton.setEnabled(false); //testButton.setEnabled(true); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } class TestClickListener implements SelectionListener { @Override public void widgetDefaultSelected(SelectionEvent e) { } @Override public void widgetSelected(SelectionEvent e) { System.out.println("Click!"); } } public static void main(String[] args) { new TestButton(); } } When I keep these 2 lines commented out - I can properly click on a button and always get "Click!" logged, but if I uncomment them - then I can't click on button properly with mouse anymore - button visually seems to be clicked, but nothing is logged... Am I doing something wrong here? Or maybe it's some kind of bug on Linux platform? Because on Mac running the same code I never experienced such problems... Thanks for any hint! P.S. Running code on Ubuntu 9.10, Gnome + Compiz, Sun Java 1.6.0.16

    Read the article

  • Updating progress dialog in Activity from AsyncTask

    - by Laimoncijus
    In my app I am doing some intense work in AsyncTask as suggested by Android tutorials and showing a ProgressDialog in my main my activity: dialog = ProgressDialog.show(MyActivity.this, "title", "text"); new MyTask().execute(request); where then later in MyTask I post results back to activity: class MyTask extends AsyncTask<Request, Void, Result> { @Override protected Result doInBackground(Request... params) { // do some intense work here and return result } @Override protected void onPostExecute(Result res) { postResult(res); } } and on result posting, in main activity I hide the dialog: protected void postResult( Result res ) { dialog.dismiss(); // do something more here with result... } So everything is working fine here, but I would like to somehow to update the progress dialog to able to show the user some real progress instead just of dummy "Please wait..." message. Can I somehow access the progress dialog from MyTask.doInBackground, where all work is done? As I understand it is running as separate Thread, so I cannot "talk" to main activity from there and that is why I use onPostExecute to push the result back to it. But the problem is that onPostExecute is called only when all work is already done and I would like to update progress the dialog in the middle of doing something. Any tips how to do this?

    Read the article

  • How to fetch data for AutoCompleteTextView in separate thread?

    - by Laimoncijus
    For my AutoCompleteTextView I need to fetch the data from a webservice. As it can take a little time I do not want UI thread to be not responsive, so I need somehow to fetch the data in a separate thread. For example, while fetching data from SQLite DB, it is very easy done with CursorAdapter method - runQueryOnBackgroundThread. I was looking around to other adapters like ArrayAdapter, BaseAdapter, but could not find anything similar... Is there an easy way how to achieve this? I cannot simply use ArrayAdapter directly, as the suggestions list is dynamic - I always fetch the suggestions list depending on user input, so it cannot be pre-fetched and cached for further use... If someone could give some tips or examples on this topic - would be great!

    Read the article

  • Google Analytics testing/sandbox environment?

    - by Laimoncijus
    Is there any Google Analytics testing/sandbox environment for testing your JS custom code before putting it to live system? I don't want to use my real tracking ID to see if everything is correct on my dev. environment, neither I want to put my code untested live... Is there any techniques or maybe some fake Analytics tracking lib I could use for testing?

    Read the article

  • How can I define an empty array in a Perl construtor?

    - by Laimoncijus
    I am just beginner with Perl, so if it sounds stupid - sorry for that :) My problem is - I am trying to write a class, which has an empty array, defined in constructor of a class. So I am doing this like this: package MyClass; use strict; sub new { my ($C) = @_; my $self = { items => () }; bless $self, ref $C || $C; } sub get { return $_[0]->{items}; } 1; Later I am testing my class with simple script: use strict; use Data::Dumper; use MyClass; my $o = MyClass->new(); my @items = $o->get(); print "length = ", scalar(@items), "\n", Dumper(@items); And while running the script I get following: $ perl my_test.pl length = 1 $VAR1 = undef; Why am I doing wrong what causes that I get my items array filled with undef? Maybe someone could show me example how the class would need to be defined so I would not get any default values in my array?

    Read the article

  • Pass data from thread into Activity

    - by Laimoncijus
    Hi, I am want to pass data back from a Thread to Activity (which created the thread). So I am doing like described on Android documentation: public class MyActivity extends Activity { [ . . . ] // Need handler for callbacks to the UI thread final Handler mHandler = new Handler(); // Create runnable for posting final Runnable mUpdateResults = new Runnable() { public void run() { updateResultsInUi(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); [ . . . ] } protected void startLongRunningOperation() { // Fire off a thread to do some work that we shouldn't do directly in the UI thread Thread t = new Thread() { public void run() { mResults = doSomethingExpensive(); mHandler.post(mUpdateResults); } }; t.start(); } private void updateResultsInUi() { // Back in the UI thread -- update our UI elements based on the data in mResults [ . . . ] } } Only one thing I am missing here - where and how should be defined mResults so I could access it from both Activity and Thread, and also would be able to modify as needed? If I define it as final in MyActivity, I can't change it anymore in Thread - as it is shown in example... Thanks!

    Read the article

  • Define an empty array in Perl class new()

    - by Laimoncijus
    Hi, I am just beginner with Perl, so if it sounds stupid - sorry for that :) My problem is - I am trying to write a class, which has an empty array, defined in constructor of a class. So I am doing this like this: package MyClass; use strict; sub new { my ($C) = @_; my $self = { items => () }; bless $self, ref $C || $C; } sub get { return $_[0]->{items}; } 1; Later I am testing my class with simple script: use strict; use Data::Dumper; use MyClass; my $o = MyClass->new(); my @items = $o->get(); print "length = ", scalar(@items), "\n", Dumper(@items); And while running the script I get following: $ perl my_test.pl length = 1 $VAR1 = undef; Why am I doing wrong what causes that I get my items array filled with undef? Maybe someone could show me example how the class would need to be defined so I would not get any default values in my array? Thanks!

    Read the article

  • Java: which configuration framework to use?

    - by Laimoncijus
    Hi, I need to decide which configuration framework to use. At the moment I am thinking between using properties files and XML files. My configuration needs to have some primitive grouping, e.g. in XML format would be something like: <configuration> <group name="abc"> <param1>value1</param1> <param2>value2</param2> </group> <group name="def"> <param3>value3</param3> <param4>value4</param4> </group> </configuration> or a properties file (something similar to log4j.properties): group.abc.param1 = value1 group.abc.param2 = value2 group.def.param3 = value3 group.def.param4 = value4 I need bi-directional (read and write) configuration library/framework. Nice feature would be - that I could read out somehow different configuration groups as different objects, so I could later pass them to different places, e.g. - reading everything what belongs to group "abc" as one object and "def" as another. If that is not possible I can always split single configuration object into smaller ones myself in the application initialization part of course. Which framework would best fit for me?

    Read the article

  • Best practice for passing configuration to each GUI object

    - by Laimoncijus
    Hi, I am writing an application, where I do have few different windows implemented, where each window is a separate class. Now I need somehow to pass a single configuration object to all of them. My GUI is designed in way, where I have one main window, which may create some child windows of its own, and these child windows can have their own childs (so there is no possibility to create all windows in initialization part and feed the config object to all of them from the very beginning)... What would be best practice for sharing this configuration object between them? Always passing via constructor or maybe making it somewhere as final public static and let each window object to access it when needed? Thanks

    Read the article

  • Proportional width of elements in LinearLayout

    - by Laimoncijus
    I have a horizontal LinearLayout and in it I have EditText and Spinner elements. Which attributes I need to adjust so I would get proportional widths: I want EditText to take 3/5 and Spinner - 2/5 of all available width? My code looks like this: <LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/LinearLayout01"> <EditText android:layout_height="wrap_content" android:id="@+id/EditText01" android:singleLine="true"> </EditText> <Spinner android:layout_height="wrap_content" android:id="@+id/Spinner01" android:layout_width="wrap_content"> </Spinner> </LinearLayout> I tried setting android:layout_weight, but somehow it does not look "stable" enough for me - when EditText has no text - everything looks fine, but as soon as I start entering text into it - it starts expanding and Spinner shrinking accordingly...

    Read the article

  • Zend Framework: Controller Plugins vs Action Helpers

    - by Laimoncijus
    Could someone give few tips and/or examples how Controller Plugins and Action Helpers are different? Are there situations where particular task could be accomplished with one but not another? For me they both look more or less the same and I'm often having trouble having to decide when to use what... Are there any big differences?

    Read the article

1