Dynamic refresh of a composite - eclipse

I have a tree viewer next to a specialized viewer. When something is selected in the tree viewer, details about this object are shown in the specialized viewer. TreeViewer tree, Composite control, and MySpecializedViewer viewer are instance variables.
public TheEverythingViewer(Composite parent) {
control = new Composite(parent, SWT.NONE);
control.setLayout(new GridLayout(2, false));
tree = new TreeViewer(control);
tree.setContentProvider(new MyContentProvider());
tree.setLabelProvider(new MyLabelProvider());
tree.setUseHashlookup(true);
tree.getControl().setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false, true, 1, 1));
tree.addSelectionChangedListener(new ISelectionChangedListener() {
#Override public void selectionChanged(SelectionChangedEvent event) {
try {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
MyClass myInput = (MyClass) sel.getFirstElement();
if (viewer != null)
if (!viewer.getControl().isDisposed())
viewer.getControl().dispose();
viewer = new MySpecializedViewer(control, table);
control.getShell().layout();
} catch (Exception e) {
if (viewer != null)
if (!viewer.getControl().isDisposed())
viewer.getControl().dispose();
viewer = null;
}
}
});
}
Am I doing something wrong? I just want:
+--------------+--------------------------------------------+
| + Node | |
| - Node | |
| + Node | My |
| - Node | |
| - Node | Specialized |
| | Viewer |
| | |
| | |
| | |
| | |
| | |
| | |
| | +--------+ |
| | | | |
| | | | |
| | | | |
| | +--------+ |
| | |
| | |
| | |
| | |
+--------------+--------------------------------------------+
The specialized viewer has tables that need to consume more or less space depending on the selected node. And currently, creating a new instance of the specialized viewer is much, much simpler than changing it's input (that wouldn't work ATM).

Yes, you shouldn't be recreating the viewer every time selection changes in your tree, you should just be sending the tree's selection to the existing viewer as its input, at which point it can do whatever you want it to do with the new input. You're also never setting the layout data on your specialized viewer's control, and then forcing the entire shell to re-layout is wasteful.

Related

in postgresql how to get the last 4 numbers from a field and copy it to a new field

I'm trying to get the last four digits of the field "SERIAL8" and put that in a new field called "SS4". Here is the query I'm trying to use but it isn't working. I'm new at this, so any help would be appreciated
SELECT * FROM CUSTOMER_TABLE
SUBSTRING (SERIAL,4,4) as 'SS4'
CUSTOMER_TABLE
+-----------------------+------------+----------+--+
| "Complaint Full Date" | Source | SERIAL | |
+-----------------------+------------+----------+--+
| 02/04/16 | DAPIS_CAIR | DG540732 | |
| 04/18/16 | DAPIS_CAIR | DG553384 | |
| 03/23/17 | RO | DG559515 | |
| 03/29/16 | CAIR | DG559781 | |
| 12/10/14 | DAPIS_CAIR | DG561621 | |
+-----------------------+------------+----------+--+

Looking for Flutter graphics classes corresponding to Android classes

I am looking into the feasibility of converting a simple open source Android chart tool to Flutter. Looking at a few Android charting tools, I find they may use the following Android imports.
Next, I am trying to identify Flutter classes that would, very roughly and loosely, correspond to the Android classes. Mostly looking by names, I find this rough mapping.
Would someone be able to point me to Flutter classes on lines with questionmarks? (Comments on the filled up lines are also great)
| Android | Flutter | Comment | Android API | Flutter API |
|-------------------------------------+-----------------+---------+---------------------------------------------------------------------------------+------------------------------------------------------------|
| android.content.Context; | ? | | https://developer.android.com/reference/android/content/Context.html | ? |
| android.util.AttributeSet; | ? | | https://developer.android.com/reference/android/util/AttributeSet.html | ? |
| android.graphics.Color; | dart:ui.Color | | https://developer.android.com/reference/android/graphics/Color.html | https://docs.flutter.io/flutter/dart-ui/Color-class.html |
| android.graphics.Canvas; | dart:ui.Canvas | | https://developer.android.com/reference/android/graphics/Canvas.html | https://docs.flutter.io/flutter/dart-ui/Canvas-class.html |
| android.graphics.Rect; | dart:ui.Rect | | https://developer.android.com/reference/android/graphics/Rect.html | https://docs.flutter.io/flutter/dart-ui/Rect-class.html |
| android.graphics.Point; | dart:math.Point | | https://developer.android.com/reference/android/graphics/Point.html | https://docs.flutter.io/flutter/dart-math/Point-class.html |
| android.graphics.Paint; | dart:ui.Paint | | https://developer.android.com/reference/android/graphics/Paint.html | https://docs.flutter.io/flutter/dart-ui/Paint-class.html |
| android.graphics.Region; | ? | | https://developer.android.com/reference/android/graphics/Region.html | ? |
| android.graphics.drawable.Drawable; | ? Picture ? | | https://developer.android.com/reference/android/graphics/drawable/Drawable.html | ? |
| android.view.View; | ? Viewport ? | | https://developer.android.com/reference/android/view/View.html | ? |
During the Android->Flutter code conversion of a graphics application, I ended up using the following mapping of classes. Except of AttributeSet that I ended up not needing, each has more or less corresponding class.
| Android | Flutter | Comment |
|---------------------------------------+------------------------------------------+-----------------------------------------------------------------|
| android.content.Context; | package:flutter:widgets.BuildContext | somewhat equivalent |
| android.util.AttributeSet; | ? | |
| android.graphics.Color; | dart:ui.Color | import 'dart:ui' as ui; // in code: ui.Color |
| android.graphics.Canvas; | dart:ui.Canvas | |
| android.graphics.Rect; | dart:ui.Rect | For operations such as "contains(Offset)" etc |
| android.graphics.Point; | dart:ui.Offset (*not* dart:math.Point) | Offset in context of graphics |
| android.graphics.Paint; | dart:ui.Paint | |
| android.graphics.Region; | dart:ui.Rect | |
| android.graphics.drawable.Drawable; | used CustomPaint - see line below | |
| android.view.View; impl Drawable | package:flutter/widgets.dart.CustomPaint | import 'package:flutter/widgets.dart' as widgets; |
| - (continuation line) | - combined with CustomPainter | - in code: widgets.CustomPaint, widgets.CustomPainter |
| android.graphics.Path | dart:ui.Path | |
| android.graphics.PathEffect | Needed for dash-lines. | there is no dash-lines effect in Dart, intentional, performance |
| android.Text (when drawing on Canvas) | package:flutter/painting.dart.TextSpan | import package:flutter/painting.dart'; |
| - (continuation line) | - *not* widgets.Text | - there are multiple *Text* classes in Dart. |
| | | - TextSpan is for drawing text on Canvas. |

Postgresql materialized view is refreshed by itself

I have this materialized view in my Postgres 9.4 database:
Materialized view "public.v_videolist"
Column | Type | Modifiers | Storage | Stats target | Description
----------+---------+-----------+----------+--------------+-------------
id | integer | | plain | |
title | text | | extended | |
embed | text | | extended | |
img | text | | extended | |
imgs | text | | extended | |
tags | text | | extended | |
category | text | | extended | |
vid | bigint | | plain | |
views | bigint | | plain | |
likes | bigint | | plain | |
unlikes | bigint | | plain | |
duration | integer | | plain | |
site | integer | | plain | |
Indexes:
"i_vl_id" UNIQUE, btree (id)
View definition:
SELECT videolist.id,
videolist.title,
videolist.embed,
videolist.img,
videolist.imgs,
videolist.tags,
videolist.category,
videolist.vid,
videolist.views,
videolist.likes,
videolist.unlikes,
videolist.duration,
videolist.site
FROM videolist
ORDER BY random();
Time to time this view refreshed by itself. There is no cron job to refresh it or something like that. It is just refreshed by itself from time to time, and I can't find who does it. I fully log all queries. There is no any refresh materialized view in the log.
Why is my view renewed? Any suggestions?
A job could be scheduled to update the statistics using this SQL statement:
REFRESH MATERIALIZED VIEW public.v_videolist;
You can use pg_cron to schedule the job.

How to create subheaders in scroll panel on GWT?

I am trying to create sub headers for the scroll table but not able to specify row span and col span.
I want to create a table like this through the scroll table.
+---------------------------------------------------------------+
| Heading1 | Heading2 | Heading3 |
| |-----------------------------| |
| |subhead1| subhead2 |subhead3 | |
| | | | | |
+---------------------------------------------------------------+
| |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
+---------------------------------------------------------------+
Anybody know how to create like this ?
I think Flex table is what you are looking for. FlexTable's FlexCellFormatter has setColSpan and setRowSpan methods that should allow you to create the headings you desire.
Haven't tested this, but the following code should set the first row as you described:
flexTable.getFlexCellFormatter().setRowSpan(0, 0, 2);
flexTable.getFlexCellFormatter().setColSpan(0, 1, 3);
flexTable.getFlexCellFormatter().setColSpan(0, 2, 2);
See the FlexTable example for source code.

Laravel Route Composer restful with no name

I'm trying to use the laravel route composer but I want it to have no name. What I mean is instead of doing /user/{id} or /user/{id}/show, I just want to have is so it's /{id} and /{id}/show like that.
Also what about having one inside it so like status, i.e.
/{id}/status/{id}/show
UPDATED: Try
Route::resource('/', 'UserController');
Route::resource('/.status', 'UserStatusController');
It will give you
+----------------------------------+----------------+------------------------------+
| URI | Name | Action |
+----------------------------------+----------------+------------------------------+
| GET|HEAD / | index | UserController#index |
| GET|HEAD create | create | UserController#create |
| POST / | store | UserController#store |
| GET|HEAD {} | show | UserController#show |
| GET|HEAD {}/edit | edit | UserController#edit |
| PUT {} | update | UserController#update |
| PATCH {} | | UserController#update |
| DELETE {} | destroy | UserController#destroy |
| GET|HEAD {}/status | status.index | UserStatusController#index |
| GET|HEAD {}/status/create | status.create | UserStatusController#create |
| POST {}/status | status.store | UserStatusController#store |
| GET|HEAD {}/status/{status} | status.show | UserStatusController#show |
| GET|HEAD {}/status/{status}/edit | status.edit | UserStatusController#edit |
| PUT {}/status/{status} | status.update | UserStatusController#update |
| PATCH {}/status/{status} | | UserStatusController#update |
| DELETE {}/status/{status} | status.destroy | UserStatusController#destroy |
+----------------------------------+----------------+------------------------------+
In your UserStatusController
class UserStatusController extends BaseController
{
public function edit($user_id, $status_id)
{
//
}
}
See Handling Nested Resource Controllers