Search in sources :

Example 1 with UpdatingTableColumnLayout

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;
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IArchiRepository(org.archicontribs.modelrepository.grafico.IArchiRepository) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IArchiRepository(org.archicontribs.modelrepository.grafico.IArchiRepository) ArchiRepository(org.archicontribs.modelrepository.grafico.ArchiRepository) IArchimateModel(com.archimatetool.model.IArchimateModel) UpdatingTableColumnLayout(com.archimatetool.editor.ui.components.UpdatingTableColumnLayout)

Example 2 with UpdatingTableColumnLayout

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) UpdatingTableColumnLayout(com.archimatetool.editor.ui.components.UpdatingTableColumnLayout)

Example 3 with UpdatingTableColumnLayout

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);
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) UpdatingTableColumnLayout(com.archimatetool.editor.ui.components.UpdatingTableColumnLayout)

Aggregations

UpdatingTableColumnLayout (com.archimatetool.editor.ui.components.UpdatingTableColumnLayout)3 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 IArchimateModel (com.archimatetool.model.IArchimateModel)1 ArchiRepository (org.archicontribs.modelrepository.grafico.ArchiRepository)1 IArchiRepository (org.archicontribs.modelrepository.grafico.IArchiRepository)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 CLabel (org.eclipse.swt.custom.CLabel)1 SashForm (org.eclipse.swt.custom.SashForm)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1