Wednesday, December 08, 2004

ClearCase

installing ClearCase on Win2000Pro in Cisco

1) Get Cliear Case from Software Tracker, remember to note reg-key

2) start installation by setup as usual

3) Configuring ClearCase for use

ClearCase Installation -Clearcase 6.0 (San Jose and Boxborough)
For San Jose distribution is available at file://warehouse/em_storage/cwtools/clearcase6.0/San-jose
For Boxborough distribution is available at file://bxb-filer02b/projects/cwtools/clearcase6.0/boxborough/nt_i386
Run setup.exe and follow the setup, clearcase will be installed and configured automatically.

Uninstall ClearCase completely if you need to reinstall it for any reason and reboot the machine.For all other site Visit Softtracker to install ClearCase 4.2.

·Select D:\atria or D:\atria directory for installation
·Select Standard Configuration option for installation
·Click Next to continue
·Select Finish to complete the installation

Decline to restart the machine

In my case i installed ClearCase in C:\ProgramFiles so i had to do things differently, which i will point as i go along.

4) Entering Lisence/Server information

- Start -> Settings -> Control Panel-> ClearCase ->Registry Refer the table above to enter the registry server, Windows Region and Peer UNIX Region. Click OK.- Click on Licensing Tab and enter the License host for your site.

The following info will be needed and can be got from the local web page

Site Name
Registry/View Server
Unix Registry Region
Windows Registry Region
License Host
Tools Root


5) Alias cleartool command (optional)

To save on the number of keystrokes you type, we highly recommend that you make a copy of the cleartool command or make an alias with a doskey macro

C:\> doskey ct=D:\atria\bin\cleartool $* (This i did not do as i installed differently as mentioned earliear)

OR make a copy of the cleartool.exe command as ct.exe.

C:\> cd
C:\bin\atria\bin
C:\> cp cleartool.exe ct.exe ( I did only this but under C:\ProgramFiles\ClearCase\bin where my clearcase is installed)

6) Environment Setting for Tools

Start -> Run file://TOOLS-ROOT/setup.batThe above command will setup the path on your Windows2000 Desktops. - this did not work for me so i manually set the env variables mentioned below, by going into MyComputers/EnvironmentVariables

NOTE: If your user path is big, it may not be updated. In this case you will need to manually add file://TOOLS-ROOT/bin/pc at the very beginning of your user path.)

set CWTOOLS to TOOLS-ROOT (refer the table above for your site specific partition)
The path for the TOOLS-ROOT is file:////warehouse/em_storage/cwtools
(The table gives the path for the TOOS-ROOT - from local web page)

set CWSCRATCH to D:\views (need to sed manually, i set these 2 envvariables manually)

IMP : Reboot the machine after ClearCase Installation.

7) Share the \views Directory

Double click on My Computer,
open D:, right click on the views folder, and select "Sharing..." from the menu. Share d:\views open to everyone.


AFTER INSTALLATION IS DONE -

1) Create a View AND DO NOT LOAD ANY ELEMENTS WHEN THE load elements dialog box pops up, just click cancel on the load element dialog box and finish creating a empty view.

2) Loading Rules

Start>ProgramFiles>Ratioanl ClearCase>ClearCase Home Base>
Click on Views Tab, Click on "Edit View Properties" button, Select on the SnapShot tab and slect
your snapshot view you just created in previous step and click OK, A dialog will pop-up. Click on the load rules tab and use the following load rules for the view

ex -
load \enm_sybase\SYBSasa9\NT
load \enm_athena
load \enm_utility
load \enm_jdk\jdk142-NT

In case if you do not want to use snapshot view (i used snapshot view) you need to mount the VOBs yourself.

NOTE - you can change the load rules any time by going to the "Properties of View" and clicking on "Load Rules" tab and editing the load rules.

Working With Branches - in Clear Case

What Is a Branch?

ClearCase uses branches to organize the different versions of files, directories and objects that are placed under version control. A branch is an object that specifies a linear sequence of versions of an element.
The entire set of an element’s versions is called a version tree. By default, ClearCase provides for every single element in a VOB one principal branch, called the main branch. This main branch may also have subbranches.
A branch type is a type object that is used to identify a parallel line of development for an element. Each branch in an element’s version tree is an instance of a branch type that exists in that element’s VOB. -->


How to include a existing Branch into your existion

Step 1) right click on your view in the explorer and go to clearcase in the drop down list and select properties, under "properties of View" there are two tabs Load Rules and Config Specs,

Click on config Specs and you will find some specs allready there

element * CHECKEDOUT
element * /main/LATEST
load \enm_sybase\SYBSasa9\NT
load \enm_athena
load \enm_utility
load \enm_jdk\jdk142-NT

you need to add the branch information as follwos in to this sopecs as shown below by clicking the Edit button at the bottom of the View Properties window


element * CHECKEDOUT
element \enm_athena\... ...\actValidate\LATEST
element \enm_athena\... \main\LATEST -mkbranch actValidate
element * /main/LATEST
load \enm_sybase\SYBSasa9\NT
load \enm_athena
load \enm_utility
load \enm_jdk\jdk142-NT

one you click apply button after editing the specs the view is updated and the elements (i.e. the files and foldres) under this branch "actValidate" in this case will appear in your view.

Important NOTE - in Cisco NMTG, the Release Engineering had put some scripts to be triggered when code were checked in using clasr case, for this reason in-order to check-in code one needed install MKS which is a software tool, that will simulate the snv 0f UNIX on wildows, which will be used to run those perl scripts that do some validation b4 it allows us to check in the code.



Tuesday, December 07, 2004

Scrolling Table Programatically

JComponent scrolling
Any JComponent has built-in support for being only partly visible (even if it does not implement Scrollable). The usual container for such purposes is JViewport, which displays only a certain part of the component (and also adds some caching). JScrollPane only adds support for headers and corner components and, important for user actions, the scroll bars to change the currently displayed part.

JComponent.getVisibleRect() returns the visible area. If it is not contained (directly or indirectly) in a JViewport or similar, it will return the whole component area.

JComponent.scrollRectToVisible() causes any scrolling containers up the container hierarchy to make the given part of the component visible. It is forwarded up until a component (like JViewport) is responsible for performing that action.

This document handles more sophisticated scrolling/visibility situations than those that are directly possible with these two methods. The methods presented here will end up calling them, but do conversions before to get more specific behaviour.

As of now, the code only works for components directly contained in a viewport-like container, not for any subcomponents. For such components,getVisibleRect() cannot be (mis-)used to obtain the size of the viewport anymore, so things get much more complicated. One has to walk up the hierarchy and search for the real viewport to get this size, which the following calculations are based on. Even if the component is the viewport's view, getVisibleRect() may return a smaller size than the viewport size - if the component is smaller than the viewport. But then scrolling is never done anyway.

Also, JTextField overrides scrollRectToVisible in a weird way, so it doesn't work as usual anymore.

Accessing component (or part) locations or sizes (or getVisibleRect()) when the component (or any of its ancestors) is invalid (isValid()) should be avoided. scrollRectToVisible() will validate the component before scrolling, so calling this method isn't the problem; but the fact that the Rectangle argument may not be sensible anymore because the layout or size may have changed.

The components that are typically contained in a JScrollPane (JTable, JList, JTable, text components) get invalid (nearly?) always when the model changes because that usually have to change their size. JList/BasicListUI seem to calculate the proper cell bounds even when changes have occured, while JTable generally has to recalculate the column widths (sizeColumnsToFit) and doesn't do that immediately. (#4172618)

Use SwingUtilities.invokeLater() to invoke the bounds-accessing code (which will then also do the scrolling) whenever you think such a change may occur. Maybe even test isValid() before doing any calculations, unless you know more about the component.

The methods sketched here are contained in runnable form in Scrolling.java.

Scrolling to areas
Common operations are scrolling to top/bottom/left/right, not to explicit areas as in the next parts.

public static final int
NONE = 0,
TOP = 1,
VCENTER = 2,
BOTTOM = 4,
LEFT = 8,
HCENTER = 16,
RIGHT = 32;

public static void scroll(JComponent c, int part)
{
scroll(c, part & (LEFTHCENTERRIGHT), part & (TOPVCENTERBOTTOM));
}

public static void scroll(JComponent c, int horizontal, int vertical)
{
Rectangle visible = c.getVisibleRect();
Rectangle bounds = c.getBounds();

switch (vertical)
{
case TOP: visible.y = 0; break;
case VCENTER: visible.y = (bounds.height - visible.height) / 2; break;
case BOTTOM: visible.y = bounds.height - visible.height; break;
}

switch (horizontal)
{
case LEFT: visible.x = 0; break;
case HCENTER: visible.x = (bounds.width - visible.width) / 2; break;
case RIGHT: visible.x = bounds.width - visible.width; break;
}

c.scrollRectToVisible(visible);
}
Scrolling with overflow policy
It is unclear how a region is scrolled when it is too large to be displayed all at once. JViewport doesn't scroll at all if only the region is visible, and scrolls the unwanted part away otherwise, but this policy could be different in another viewport container (for example always scrolling the upper-left corner into view). Sometimes it may be desired to be sure that no scrolling happens in the former case, or suggest which part should really be made visible.

Some methods here take a bias argument, which is used in such a situation and one of the following constants (which values they actually have of course does not matter):

public static final int
VIEWPORT = 0, // take the policy of the viewport
UNCHANGED = 1, // don't scroll if it fills the visible area, otherwise take the policy of the viewport
FIRST = 2, // scroll the first part of the region into view
CENTER = 3, // center the region
LAST = 4; // scroll the last part of the region into view
Here is scrollRectToVisible() with biases:

public static void scroll(JComponent c, Rectangle r, int horizontalBias, int verticalBias)
{
Rectangle visible = c.getVisibleRect(),
dest = new Rectangle(r);

if (dest.width > visible.width)
{
if (horizontalBias == VIEWPORT)
{
// leave as is
}
else if (horizontalBias == UNCHANGED)
{
if (dest.x <= visible.x && dest.x + dest.width >= visible.x + visible.width)
{
dest.width = visible.width;
}
}
else
{
if (horizontalBias == CENTER)
dest.x += (dest.width - visible.width) / 2;
else if (horizontalBias == LAST)
dest.x += dest.width - visible.width;

dest.width = visible.width;
}
}

if (dest.height > visible.height)
{
// same code as above in the other direction
}

if (!visible.contains(dest))
c.scrollRectToVisible(dest);
}
Scrolling in one direction
scrollRectToVisible() always takes a Rectangle argument. Sometimes it may be desired to only scroll vertically or horizontally, not in both directions, for example to make a certain row in a JTable visible. The code for horizontal and vertical scrolling is completely analogous, here only one variant is shown.

The following method is given a range (from: inclusive, to: exclusive) to make visible.

public static void scrollHorizontally(JComponent c, int from, int to)
{
Rectangle visible = c.getVisibleRect();

if (visible.x <= from && visible.x + visible.width >= to)
return;

visible.x = from;
visible.width = to - from;

c.scrollRectToVisible(visible);
}
As many accessor methods (like JList.getCellBounds()) still return Rectangles, a Rectangle argument can be given, from which only the desired direction will be honored.

public static void scrollHorizontally(JComponent c, Rectangle r)
{
scrollHorizontally(c, r.x, r.x + r.width);
}
Additionally, you may want to specify a bias for possibly large areas.

public static void scrollHorizontally(JComponent c, int from, int to, int bias)
{
Rectangle visible = c.getVisibleRect(),
dest = new Rectangle(visible);

dest.x = from;
dest.width = to - from;

// same adjusting code as above

if (!visible.contains(dest))
c.scrollRectToVisible(dest);
}
Centering
Just scrolling sections into view may not be the best thing to do because the area in question may just barely appear at the top/bottom and thus not be considered important by the user. A better choice can be to scroll it into the center of the currently visible section (if this is possible, it can of course not be done for the first/last areas/rows/columns).

Not scrolling into the insets area is here for consistency. If the insets were always ignored, centering would scroll the insets of "view" components (JTable, JList, JTree) into view, while normal scrolling would not because the area accessors of these components never include the insets.

public static void center(JComponent c, Rectangle r, boolean withInsets)
{
Rectangle visible = c.getVisibleRect();

visible.x = r.x - (visible.width - r.width) / 2;
visible.y = r.y - (visible.height - r.height) / 2;

Rectangle bounds = c.getBounds();
Insets i = withInsets ? new Insets(0, 0, 0, 0) : c.getInsets();
bounds.x = i.left;
bounds.y = i.top;
bounds.width -= i.left + i.right;
bounds.height -= i.top + i.bottom;

if (visible.x < x =" bounds.x;"> bounds.x + bounds.width)
visible.x = bounds.x + bounds.width - visible.width;

if (visible.y < y =" bounds.y;"> bounds.y + bounds.height)
visible.y = bounds.y + bounds.height - visible.height;

c.scrollRectToVisible(visible);
}
Testing for visibility
public static boolean isVisible(JComponent c, Rectangle r)
{
return c.getVisibleRect().contains(r);
}

public static boolean isHorizontallyVisible(JComponent c, int from, int to)
{
Rectangle visible = c.getVisibleRect();

return visible.x <= from && visible.x + visible.width >= to;
}


##############################################################

GOOD HELP FOR SWING IS HERE
http://javaalmanac.com/egs/javax.swing.table/pkg.html

##############################################################

e948. Scrolling a Cell to the Center of a JTable ComponentThis example demonstrates how to scroll the view so that a specified cell appears in the center of the view. // Make the cell (1,2) is appear in the center of the view
int rowIndex = 1;
int vColIndex = 2;
scrollToCenter(table, rowIndex, vColIndex);

// Assumes table is contained in a JScrollPane. Scrolls the
// cell (rowIndex, vColIndex) so that it is visible at the center of viewport.
public void scrollToCenter(JTable table, int rowIndex, int vColIndex) {
if (!(table.getParent() instanceof JViewport)) {
return;
}
JViewport viewport = (JViewport)table.getParent();

// This rectangle is relative to the table where the
// northwest corner of cell (0,0) is always (0,0).
Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);

// The location of the view relative to the table
Rectangle viewRect = viewport.getViewRect();

// Translate the cell location so that it is relative
// to the view, assuming the northwest corner of the
// view is (0,0).
rect.setLocation(rect.x-viewRect.x, rect.y-viewRect.y);

// Calculate location of rect if it were at the center of view
int centerX = (viewRect.width-rect.width)/2;
int centerY = (viewRect.height-rect.height)/2;

// Fake the location of the cell so that scrollRectToVisible
// will move the cell to the center
if (rect.x < centerX) {
centerX = -centerX;
}
if (rect.y < centerY) {
centerY = -centerY;
}
rect.translate(centerX, centerY);

// Scroll the area into view.
viewport.scrollRectToVisible(rect);
}




This page is powered by Blogger. Isn't yours?