use of com.archimatetool.editor.ui.components.UpdatingTableColumnLayout in project archi-modelrepository-plugin by archi-contribs.
the class HistoryView method selectionChanged.
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (part == this) {
return;
}
Object selected = ((IStructuredSelection) selection).getFirstElement();
IArchiRepository selectedRepository = null;
// Repository selected
if (selected instanceof IArchiRepository) {
selectedRepository = (IArchiRepository) selected;
} else // Model selected, but is it in a git repo?
{
IArchimateModel model = part.getAdapter(IArchimateModel.class);
if (GraficoUtils.isModelInLocalRepository(model)) {
selectedRepository = new ArchiRepository(GraficoUtils.getLocalRepositoryFolderForModel(model));
}
}
// Update if selectedRepository is different
if (selectedRepository != null && !selectedRepository.equals(fSelectedRepository)) {
// Set label text
// $NON-NLS-1$
fRepoLabel.setText(Messages.HistoryView_0 + " " + selectedRepository.getName());
getViewer().setInput(selectedRepository);
// Do the table kludge
((UpdatingTableColumnLayout) getViewer().getTable().getParent().getLayout()).doRelayout();
// Update actions
fActionExtractCommit.setRepository(selectedRepository);
// fActionRevertSingleCommit.setRepository(selectedRepository);
fActionRevertUptoCommit.setRepository(selectedRepository);
fActionRestoreCommit.setRepository(selectedRepository);
fActionUndoLastCommit.setRepository(selectedRepository);
fActionResetToRemoteCommit.setRepository(selectedRepository);
// Select first row
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (!getViewer().getTable().isDisposed()) {
Object element = getViewer().getElementAt(0);
if (element != null) {
getViewer().setSelection(new StructuredSelection(element));
}
}
}
});
// Store last selected
fSelectedRepository = selectedRepository;
}
}
use of com.archimatetool.editor.ui.components.UpdatingTableColumnLayout in project archi by archimatetool.
the class AbstractArchiPropertySection method createTableComposite.
/**
* Create Composite control to hold a Table control with UpdatingTableColumnLayout
* @param parent
* @param style
* @return Composite control
*/
protected Composite createTableComposite(Composite parent, int style) {
Composite tableComp = new Composite(parent, style);
// This ensures a minumum and equal size and no horizontal size creep
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 100;
gd.heightHint = 50;
tableComp.setLayoutData(gd);
tableComp.setLayout(new UpdatingTableColumnLayout(tableComp));
return tableComp;
}
use of com.archimatetool.editor.ui.components.UpdatingTableColumnLayout in project archi-modelrepository-plugin by archi-contribs.
the class HistoryView method createPartControl.
@Override
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.verticalSpacing = 0;
parent.setLayout(layout);
fRepoLabel = new CLabel(parent, SWT.NONE);
fRepoLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fRepoLabel.setText(Messages.HistoryView_0);
SashForm sash = new SashForm(parent, SWT.VERTICAL);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
sash.setLayoutData(gd);
Composite tableComp = new Composite(sash, SWT.NONE);
// This ensures a minumum and equal size and no horizontal size creep
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 100;
gd.heightHint = 50;
tableComp.setLayoutData(gd);
tableComp.setLayout(new UpdatingTableColumnLayout(tableComp));
// Create the Viewer first
fTableViewer = new HistoryTableViewer(tableComp);
// Comments Viewer
fCommentViewer = new RevisionCommentViewer(sash);
sash.setWeights(new int[] { 80, 20 });
makeActions();
hookContextMenu();
// makeLocalMenuActions();
makeLocalToolBarActions();
// Register us as a selection provider so that Actions can pick us up
getSite().setSelectionProvider(getViewer());
/*
* Listen to Selections to update local Actions
*/
getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateActions(event.getSelection());
}
});
/*
* Listen to Double-click Action
*/
getViewer().addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
}
});
// Listen to workbench selections
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
// Register Help Context
PlatformUI.getWorkbench().getHelpSystem().setHelp(getViewer().getControl(), HELP_ID);
// Initialise with whatever is selected in the workbench
IWorkbenchPart part = getSite().getWorkbenchWindow().getPartService().getActivePart();
if (part != null) {
selectionChanged(part, getSite().getWorkbenchWindow().getSelectionService().getSelection());
}
// Add listener
RepositoryListenerManager.INSTANCE.addListener(this);
}
Aggregations