Display Bold, Italic, Strike out fonts in SWT table/tree

Posted on Updated on

SWT(Software Widget toolkit). It’s a java based framework to develop GUI(standalone) applications. This framework is like Java Swings, AWT. SWT has rich set of widgets like tree, tables, groups, sahsforms, composites etc.

Usecase: Let’s say user has some valid data which is going to change dynamically some new data is added, some data is edited, deleted and some unchanged. If user wants to have keep track of which data is changed, deleted, added, etc. then the following technical blog is helpful.

Well, SWT is derived from the Java web development they are related to each other but further you should have SWT jar files if you want to execute this code.

SWT has given direct support to show the font styles, but its up to you how you want to show them.
In this blog we are showing four types of styles

  1.  Bold
  2. Bold and italic
  3. Strike out
  4. No style

SWT Table or tree

Enum:
/**
* The Enum FontStyleStatus.
This ENUM is used to provide the different styles to text
Based on the status
*/
public enum FontStyleStatus
{
UNCHANGED,
ADDED,
RENAMED,
DELETED
}

Codes Snippet to create table:

Display display = new Display();
Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setText(“Styled text example”);
shell.setLayout(new FillLayout());

Composite container = new Composite(shell, SWT.NONE);
container.setLayout(new FormLayout());
final FormData containerFd = new FormData();
containerFd.top = new FormAttachment(0, 30);
containerFd.left = new FormAttachment(0, 4);
containerFd.right = new FormAttachment(100, -5);
containerFd.bottom = new FormAttachment(100, 0);
container.setLayoutData(containerFd);

tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
tableViewer.setContentProvider(new ContentProvider());
ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.RECREATE);

table = tableViewer.getTable();
final FormData fdFroTable = new FormData();
fdFroTable.top = new FormAttachment(0, 5);
fdFroTable.left = new FormAttachment(0, 4);
fdFroTable.right = new FormAttachment(100, -15);
fdFroTable.bottom = new FormAttachment(100, -35);
table.setLayoutData(fdFroTable);
table.setLinesVisible(true);
table.setHeaderVisible(true);

shell.setSize(400, 400);
shell.open();

final MyStyledLabelProvider labelProvider2 = new MyStyledLabelProvider();
final TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
final TableColumn tableColumn = tableViewerColumn.getColumn();
tableColumn.setWidth(100);
tableViewerColumn.setLabelProvider(new MyStyledLabelProvider2(tableViewer, 0, labelProvider2));
tableColumn.setText(“Column1”);

final TableViewerColumn tableViewerColumn2 = new TableViewerColumn(tableViewer, SWT.NONE);
tableViewerColumn2.setLabelProvider(new MyStyledLabelProvider2(tableViewer, 1, labelProvider2));
final TableColumn tableColumn2 = tableViewerColumn2.getColumn();
tableColumn2.setWidth(100);
tableColumn2.setText(“Column2″);

Collection<ValuObject> valuObjects = new ArrayList<>();
for (int i = 0; i < 20; i++)

{
ValuObject valuObject = new ValuObject();
valuObject.setValue1(” Value ” + i);
valuObject.setValue2(” Value” + i);
if (i % 2 == 0)

{
valuObject.setFontStatus(FontStyleStatus.ADDED);
}

else if (i % 3 == 0)

{
valuObject.setFontStatus(FontStyleStatus.DELETED);
}

else if (i % 5 == 0)

{
valuObject.setValue1(” 1 Before edit Value , After edit “);
valuObject.setValue2(” 2 Before edit Value , After edit”);
valuObject.setFontStatus(FontStyleStatus.RENAMED);
}
valuObjects.add(valuObject);
}

tableViewer.setInput(valuObjects);

while (!shell.isDisposed())

{
if (!display.readAndDispatch())
display.sleep();
}

display.dispose();

Value Holder or Value Object to populate table

private class ValuObject
{
private String value1;
private String value2;
private FontStyleStatus fontStatus;
public String getValue1()
{
return value1;
}
public void setValue1(String value1)
{
this.value1 = value1;
}
public String getValue2()
{
return value2;
}
public void setValue2(String value2)
{
this.value2 = value2;
}
public FontStyleStatus getFontStatus()
{
return fontStatus;
}
public void setFontStatus(FontStyleStatus fontStatus)
{
this.fontStatus = fontStatus;
}
}

 

  • While setting the input values itself set the corresponding style you want to display so that from the label provider we can display
  • For the table viewer columns set styled label provider and this should extend StyledCellLabelProvider otherwise we can’t get the styles.
  • As this class is from the Framework it has update method, we have to override this method to get our desired styles.
  • This label provider will be called for each and every column and each and every cell.

Code snippet for StyledLabelProvider:

public static class MyStyledLabelProvider2 extends StyledCellLabelProvider
{
private MyStyledLabelProvider myStyledLabelProvider;
private int index;
public MyStyledLabelProvider2(Viewer treeViewer, int index, MyStyledLabelProvider myStyledLabelProvider)
{
this.myStyledLabelProvider = myStyledLabelProvider;
this.index = index;
}
/**
* {@inheritDoc}
*/
@Override
public void update(ViewerCell cell)
{
final StyledString styledString = myStyledLabelProvider.getStyledString(cell, index);
if (styledString != null)
{
cell.setText(styledString.toString());
cell.setStyleRanges(styledString.getStyleRanges());
}
super.update(cell);
}
}

As we have override update method, this label provider actually sets the styles to the table cells, from this label provider we need to get the actual styles that’s the reason we passed one more label provider with the corresponding column index.

StyleRange, StyledString are the framework classes to provide styling for the text.
You can have a plentt of tutorials about them.

Code snippet to get actual style

Styler is the framework class which provides the styles for the text like bold, strike out etc.
We have to define the required styles. We have some predefined styles also.

/** The strike out styler. */
private Styler strikeOutStyler = new Styler()
{
@Override
public void applyStyles(TextStyle textStyle)
{
textStyle.strikeout = true;
}
};
/** The bold italic styler. */
private Styler boldItalicStyler = new Styler()
{
@Override
public void applyStyles(TextStyle textStyle)
{
textStyle.font = FontStyles.getBoldItalicFont();
}
};
/**
* Instantiates a new my styled label provider.
*/
public MyStyledLabelProvider()
{
}
public StyledString getStyledString(final ViewerCell cell, int columnIndex)
{
final Object element = cell.getElement();
final StyledString styledString = getStyledString(element, columnIndex);
return styledString;
}
private StyledString getStyledString(final Object element, final int columnIndex)
{
StyledString styledString = null;
switch (columnIndex)
{
case 0:
ValuObject value = (ValuObject) element;
styledString = new StyledString(value.getValue1(), boldItalicStyler);
if (value.getFontStatus() == null ||value.getFontStatus().equals(FontStyleStatus.UNCHANGED))
{
styledString = new StyledString(value.getValue1());
}
else if (value.getFontStatus().equals(FontStyleStatus.DELETED))
{
styledString = new StyledString(value.getValue1(),strikeOutStyler);
}
else if (value.getFontStatus().equals(FontStyleStatus.ADDED))
{
styledString = new StyledString(value.getValue1(),
boldItalicStyler);
}
else if (value.getFontStatus().equals(FontStyleStatus.RENAMED))
{
final String[] strings = value.getValue1().split(“,”);
StyledString styledString2 = new StyledString(strings[1]);
styledString = new StyledString(strings[0], strikeOutStyler);
styledString.append(styledString2);
}
break;
case 1:
ValuObject value2 = (ValuObject) element;
if (value2.getFontStatus() == null ||value2.getFontStatus().equals(FontStyleStatus.UNCHANGED))
{
styledString = new StyledString(value2.getValue2());
}
else if (value2.getFontStatus().equals(FontStyleStatus.DELETED))
{
styledString = new StyledString(value2.getValue2(),
strikeOutStyler);
}
else if (value2.getFontStatus().equals(FontStyleStatus.ADDED))
{
styledString = new StyledString(value2.getValue2(),
boldItalicStyler);
}
else if (value2.getFontStatus().equals(FontStyleStatus.RENAMED))
{
final String[] strings = value2.getValue2().split(“,”);
StyledString styledString2 = new StyledString(strings[1]);
styledString = new StyledString(strings[0], strikeOutStyler);
styledString.append(styledString2);
}
break;
default:
break;
}
return styledString;
}
}
Font Data:
public final static class FontStyles
{
private static FontData[] italicValues;
private static FontData[] boldItalicValues;
public static FontData[] getItalicFontData() {
return italicValues;
}
public static Font getBoldItalicFont()
{
if (getItalicFontData() == null)
{
final Font originalFont = Display.getCurrent().getSystemFont();
boldItalicValues = originalFont.getFontData();
for (int i = 0; i < boldItalicValues.length; i++)
{
boldItalicValues[i].setStyle(boldItalicValues[i].getStyle() |SWT.ITALIC | SWT.BOLD);
}
}
return new Font(Display.getCurrent(), boldItalicValues);
}

}

Snapshot before applying styles:

SWT table

If you observe the above screenshot the there is no styles inside the cells.

Snapshot after applying the styles:

SWT table1

You can observe the text inside the cells are bold, bold-italic, strike out, strike out and normal and normal the various styles are displayed. Even we can change the background, font color also.

Conclusion:

This article discuss about you how to display the text font inside the table or tree with styles by sing styled text, styles and styles label provider class as these are from framework.
This blog has 3 parts:

  1. Table/tree creation.
  2. Creating the table data and while creating data itself we have to specify the style you want to display. It’s just a simulation real time it depends on the functionality.
  3. Setting the styled label provider and overriding the update method. This is very important step, from this method we have to get the actual styles. This method displays actual styles.

Hope this blog is helpful.

Considering iOS App Development as a Freelance Activity

Posted on Updated on

iOS app development is in a very good form in the markets of software making. In fact it is the time someone very much interested in iOS app development takes a step forward and become a full fledged app developer and takes up the opportunity to showcase your extraordinary programming skills. iOS app development is under a great demand in the Apple store too. The popularity of iOS is increasing day by day, but the number of iOS apps is not. This is clearly creating a great demand for the iOS app development enthusiasts.

IOS app development as a freelance activity

One has 2 options when he wants to get into a full time career of iOS app development. He either works for a firm that is into iOS app making or he becomes a freelancer and starts to develop and deploy his own applications. Freelancing is always a better option if you have a little entrepreneurial approach and independent character. There are a few things to be considered while choosing the freelancing approach. Some common mistakes are generally found to be done by freelancer app makers. Let us go through them for a better understanding.

Firstly, spending enough time on research and ideation is important. No app will be a success without a perfect idea that can find an audience of its own. iOS app development is not just about coding. Making a perfect work schedule and dividing the app development process into convenient parts like pre-production, coding and post-production can help in organizing the process in a much better way.

Making a totally free application is a blunder while considering iOS app development. Even if you are launching your first every iOS application and you want to deploy it on the store, don’t make it a completely free app. A good way will be releasing a free version with limited access and features and then upgrading it to a paid version of full edition. This will not only fetch you money in your initial stages but also will tell you clearly an audience opinion on your app through the free versions status of success or failure. Also, consider the fact that iOS devices are costly and no iOS user will value any freely available app even if it is the best of its kind.

iOS app development has seen a lot of progress in the recent times. We have got automated platforms and IDEs for developing applications in iOS. You need not develop everything from scratch. Make use of the tools available in a perfect fashion. Take advantage of available packages wherever possible. No user really cares about how its’ made, everyone only concentrates on what it can do.

With all these considerations in mind, go for iOS app development for a bright career and opportunities.

Recommended :

Programming Assignment Help is a programmers choice!

Posted on

Ohho! Programming assignment help? Need someone who will help you complete your work on time? Then, don’t worry we are there for you. Just look around and we are always ready for your help. There might be cases when you opt for a programming language, the class, in that case, you certainly don’t have any problems. But in case, if you have no classes, then it creates havoc for you to complete your programming assignments on time. Just in case, if you have a mentor who can guide you, then you can crack all your programming assignments, but that happens too rarely. There are assignments which can actually range in complexity from a simple ‘Hello world’ to the programs that are far complicated. They help in adding new features that can be simply simple or bit complicated.

Why the students actually face problems?

 There can be many reasons as to why students face problems that are actually pursuing their graduation or post graduation in computer science. But the very first reason is that colleges teach theoretical stuff all based on the subjects. No practical knowledge is given to the students. Sometimes, it really gets very difficult in learning the programming languages at a relative ease. The major struggle starts on the point that programming is a bit of a headache. So, this is where an angel comes to your rescue. The main reason for hiring a mentor is that he will help you in teaching all the fundamental ABCs of programming language and will also guide you in executing the programs. The desktop applications, the web applications, and various other applications can work with relative ease by doing programming. In cases, there are changes in the style of the syntax then you need to consider the fact that programming help will actually change your look out.

How we rescue you?

Well, with the strong support of professionals, we are always there for your help 24*7 to provide you with the best in everything.  There are cases when your pocket requirements don’t actually meet your needs, but no worries, we are here for your assistance. We provide the best solutions are affordable prices. The programming assignment help is meant to provide the fundamental assistance very quickly. And that’s the main reason we also provide 100% plagiarism free work for all our student clients.  Not only this, we do provide quick assistance whenever you need it. We are just a call away!

Benefits to leverage from asp.net development providers | asp.net development

Posted on Updated on

Today in the modern era where the IT industry is completely dependent on the web arena, asp.net which is a very great combination of the Active Server Pages and the .Net framework, has been equipping the world with simple and easy ways to create an impressive, responsive and dynamic web applications.

Asp.net development hosts a lot of great features for users and is a simplified yet eminent process in contrast to the conventional application development. Alongside being a great platform for web applications development, asp.net is developers’ favorite platform too for various reasons.

Asp .net Development

Let’s go through some of the most elegant features of asp.net development

E-Pay
Giving users excellent payment flexibility in all possible modes, businesses can integrate e-pay segment in their existing website making payment easy for either of the parties.

SEO in sync with Clean URLs

To best facilitate search engine optimization for your website, you can carefully apply clean URLs to your website and make it even more prominent in the users’ space.

Security enhancement

One can strengthen the security of the website by including protection against SQL injections.

Including transfer of data

In some cases a website may not support export and import in one of the website modules and in such scenarios, you can do the needful through asp.net and successfully include the feature in those modules.

Reporting

Reports are the most important elements in any businesses as they facilitate easy and better decision making, especially for the management. In asp.net development platform once can easily add the feature of business intelligence reporting with impressive GUI appeal which can also have graphs, charts, and diagrams for easy understanding. This in turn saves lot of time and money.

News
To keep your users aware of the latest updates or technology trends, in the process of asp.net development, you can add a news-ticker to your website and see the news scroll on the website adding more viewership.

Bulk emails
Businesses have a lot of subscribers and often look for upgrading in the existing application where they can send a common email to everyone at once instead of sending mails in different batches. This is possible through asp.net.

Asp.net development also facilitates database cleaning, front-end view updating, CSS issues solving and optimization of the SQL query. Therefore, asp.net has all the best features a business requires.

Java Development Team Rebooting In 20s

Posted on Updated on

The Java Development Team have been through a number of Java reboots. But, let’s date back and see how the era of the 20s gave Java a big boost which was actually needed to make Java as the most popular language. Remembering programming era in 1995, it was very tough, though. We didn’t have even a single source to do programming at its best. Writing codes and then making them work wouldn’t have been so much easier as in the era of 20s. The object-oriented paradigm is one of the best sources to make coding very easy and also very interesting. Read the rest of this entry »

Microsoft bulletin to aware developers on security updates in .net

Posted on Updated on

Microsoft has releases two security updates in monthly bulletin – MS15-080 – Critical and MS15-092 – Important. The update resolves security related vulnerabilities in .net framework. The most threatening problem with dot net framework was execution of remote code especially when user visits some non-trusted web link.

services-ban

The next problem is related to information disclosure where data could be stolen even from most trusted apps by altering its permissions. In plenty of cases, attackers may force users to run apps even if it is not required. Hire .net developers from NexSoftSys to avoid these security attacks and to get highly safe application less suspected to their party attacks.

MS15-080 – Critical

This security update resolves vulnerabilities for Microsoft dot net framework, Windows, and SilverLight. The most threatening problem with dot net framework was execution of remote code especially when user visits some non-trusted web link. This update was rated as critical by development team due to its affects and behavior. It addresses main security issues that can affect your app adversely.

There are many software reported this problem and faced potential attack from third part users there was an immediate need to address this problem and it was successfully handled by Microsoft this year. You should hire .net developers from reputed Company to security threats and similar problems.

MS15-092 – Important

This security update resolves problem of unwanted access to app by modifying software privileges. Here, data could be stolen even from most trusted apps by altering its permissions. In plenty of cases, attackers may force users to run apps even if it is not required.

hire .net developers -nexsoftys

This update will surely be beneficial for the developers using framework 4.6 for app development. The problem was rate important by development team based on its nature and behavior.

To avoid all these security threats to safe execution of code, hire .net developers from NexSoftSys now, we are ready to help you with always with more scalable and flexible .net solutions.

Asp.net mvc development, saying it all in terms of models, views and controllers

Posted on Updated on

Technology has always offered man a pace of living. Well, this statement is do-able with the development and the changes in the way man has given development a platform to reach height. People working in the MNCAsp. net developmentS have well acquainted with all the programming languages for which even if I start counting my day would end in the unconditional mode. Well, to also add a bit, the latest programming language added to the list is ASP.NET MVC. Now, what excitement does this programming language holds in? Well, I’ll tell you, just switch your eyes to the next paragraph.

ASP.NET MVC says what?

Frankly speaking, this language has three components, talking the Model-View-Controller (MVC). This language provides an alternative solution to the ASP.NET Web forms pattern for the construction of Web applications. Simply like a normal web based interaction, the ASP.NET MVC application helps in responding the requests and then also responding back to the web browser in the similar pattern. Talking about the ASP.NET MVC, it is a light weighted and also a presentable platform which is enveloped into the ASP.NET feature. This is an application core that provides a random answer to the questions relating with the displaying of the data in an approx private manner.

Segmentation of Models, views and controller:

The ASP.NET MVC development model is synchronized into three steps. They are models, views and also controllers. Now let’s have a closer look on these segments:

Models: Model objects are those parts of the applications which have been used to implement logic for the application of the data domain. Generally, these models are used to store, retrieve and access data from the database. The model is usually conceptual and it talks a bit on the data set and helps in viewing the application in a class.

Views: Views are the components which have been used to display the applications in all the user interfaces, for which a UI is created for the model.

Controllers: These are the components which have been used to handle the user interaction and then select a view to see the UIs.

The MVC controller is helpful in the creation of applications which are different from the
applications which help in providing a coupling of elements in the nodes. The pattern is thus helpful in determining the logic which is shared and located in the application.

Test-driven development for the UIs:

These ASP.NET applications are at times complex, because the reason is that in order to test a page, you need to instantiate a class. The MVC therefore helps in coupling of the applications that are based on testing of the MVC applications.

Let’s highlight the advantages of ASP.NET development application:

• Managing complexities is very easy in this process by the segregation of the component into three applications.

• This language is easily deployed for the programmers who have full control of the applications in an easy way.

• There is a better support for the test-driven application.

Thus, today programmers need to emphasis on the growing areas of ASP.NET development which would not only expand their ideologies for learning this language, but will also help in learning a rich routing infrastructure too.

Hire asp.net developers help you to get start with Bootstrap

Posted on Updated on

Twitter Bootstrap framework is widely accepted CSS framework as it has a massive supporting ecosystem in themes, tutorials, components, and the likes. Due to popularity of Bootstrap, it has grown quite large over time and has a lot of excess CSS classes that are presently not used by user application. To know about the enhancements made to Bootstrap, you can hire asp.net developers who are already well-versed in technology and have full knowledge about the framework.

To make a quick start, you need to create a new project in Visual Studio 2013 as the default asp.net web app template has Bootstrap by default. You can add Bootstrap Nugget Package as it includes complete Bootstrap CSS and JavaScript files and Glyph icons Halflings icon font. Make sure that the files are placed inside the apt folders (\content, \Scripts, and \fonts) and set up the default bundles in BundleConfig class to include these.

LESS Source

In case the default Bootstrap package size is not as per your wish and you would like to control on the things to include, you can go with LESS Source by installing BootStrap Less Source Nuget package. It will install the LESS Source for BootStrap and you will be able to create his own LESS file and could include only desird parts of BootStrap. You can also use LESS compiler to develop a CSS file.

Manual

You can surely do it manually by navigating to BootStrap website, downloading it and copying the files into your project folder structure. There is a feature in BootStrap website that allows you to customize the parts you wish to download.

How to use bootstrap?

The official BootStrap website contains all significant information and samples. You can read them to learn how to use BootStrap.

asp net developers

The Grid

BootStrap grid is powerful and let web developers to easily develop responsive websites.

Youtube

Ample of video tutorials are available on youtube. You can also learn the techniques and steps to use BootStrap framework.

If you don’t want to take a pain, just hire asp.net developers who possess complete knowledge about BootStrap.