Compare commits
17 Commits
bhe/bugfix
...
csun/bugfi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9d5c32b50 | ||
|
|
eee3febc64 | ||
|
|
fb350a5c17 | ||
|
|
ca6cc22ba0 | ||
|
|
69fa22f6f5 | ||
|
|
db654746c1 | ||
|
|
513997726f | ||
|
|
cda9d85938 | ||
|
|
c028037013 | ||
|
|
9628d3377a | ||
|
|
cea69e78d5 | ||
|
|
6063838154 | ||
|
|
ba13aa44e0 | ||
|
|
df65549c46 | ||
|
|
87f5232e74 | ||
|
|
1fcea62d28 | ||
|
|
77833ed44c |
@@ -8,7 +8,7 @@
|
||||
<discovery label="Talend web site" url="http://www.talend.com"/>
|
||||
</url>
|
||||
<requires>
|
||||
<import plugin="org.bouncycastle.bcprov" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.bouncycastle.bcprov" version="1.68.0" match="greaterOrEqual"/>
|
||||
<import plugin="com.fasterxml.jackson.core.jackson-databind" version="2.9.8" match="greaterOrEqual"/>
|
||||
<import plugin="jackson-core-asl" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="jackson-mapper-asl" version="0.0.0" match="greaterOrEqual"/>
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<import plugin="org.eclipse.compare" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.eclipse.compare.core" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.ops4j.pax.url.mvn" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.eclipse.collections" version="0.0.0" match="greaterOrEqual"/>
|
||||
</requires>
|
||||
<plugin id="org.talend.core" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
|
||||
<plugin id="org.talend.core.nl" download-size="0" install-size="0" version="0.0.0" fragment="true" unpack="false"/>
|
||||
|
||||
@@ -38,5 +38,7 @@
|
||||
<import plugin="org.slf4j.api" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.slf4j.impl.log4j12" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.eclipse.wst.server.discovery" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.eclipse.ui.genericeditor" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.eclipse.e4.ui.ide" version="0.0.0" match="greaterOrEqual"/>
|
||||
</requires>
|
||||
</feature>
|
||||
|
||||
BIN
main/plugins/org.talend.common.ui.runtime/icons/lowercase.jpg
Normal file
BIN
main/plugins/org.talend.common.ui.runtime/icons/lowercase.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
main/plugins/org.talend.common.ui.runtime/icons/uppercase.jpg
Normal file
BIN
main/plugins/org.talend.common.ui.runtime/icons/uppercase.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 404 B |
@@ -132,3 +132,8 @@ GlobalServiceRegister.ServiceNotRegistered=The service {0} has not been register
|
||||
MessageBoxExceptionHandler.showMessageForSchemaImportXml.unParseXML.title=The xml can't parse.
|
||||
MessageBoxExceptionHandler.showMessageForSchemaImportXml.unParseXML.msg=The xml can't parse in this format.
|
||||
HibernateUtils.auditDBIsNotUsable=The audit database must be empty or only contains tables related to audit.
|
||||
CasePushButton.CaseButton.Tip=Uppercase/Lowercase Db column
|
||||
QuotePushButton.QuoteButton.Tip=Add/Remove Quote on Db column
|
||||
QuoteManipulateDialog.title=Add/Remove quote on Db column
|
||||
QuoteManipulateDialog.addQuote=Add quote
|
||||
QuoteManipulateDialog.removeQuote=Remove quote
|
||||
|
||||
@@ -88,6 +88,8 @@ public enum EImage implements IImage {
|
||||
LEFTX_ICON("/icons/leftx.png"), //$NON-NLS-1$
|
||||
RIGHT_ICON("/icons/right.gif"), //$NON-NLS-1$
|
||||
RIGHTX_ICON("/icons/rightx.png"), //$NON-NLS-1$
|
||||
LOWERCASE_ICON("/icons/lowercase.jpg"), //$NON-NLS-1$
|
||||
UPPERCASE_ICON("/icons/uppercase.jpg"), //$NON-NLS-1$
|
||||
|
||||
KEY_ICON("/icons/key.gif"), //$NON-NLS-1$
|
||||
HIERARCHY_ICON("/icons/hierarchicalLayout.gif"), //$NON-NLS-1$
|
||||
|
||||
@@ -14,7 +14,7 @@ package org.talend.commons.ui.runtime.swt.celleditor;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.eclipse.jface.util.Assert;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.viewers.CellEditor;
|
||||
import org.eclipse.jface.viewers.ComboBoxCellEditor;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.jface.util.Assert;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.viewers.CellEditor;
|
||||
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||
import org.eclipse.jface.viewers.ColumnPixelData;
|
||||
|
||||
@@ -22,7 +22,7 @@ package org.talend.commons.ui.runtime.swt.tableviewer.behavior;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.util.Assert;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||
import org.eclipse.jface.viewers.ColumnPixelData;
|
||||
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||
|
||||
@@ -32,10 +32,12 @@ import org.talend.commons.i18n.internal.Messages;
|
||||
*/
|
||||
public interface ITaCoKitService {
|
||||
|
||||
void start() throws Exception;
|
||||
void start();
|
||||
|
||||
boolean isStarted() throws Exception;
|
||||
|
||||
void waitForStart();
|
||||
|
||||
String reload(IProgressMonitor monitor) throws Exception;
|
||||
|
||||
boolean isTaCoKitCar(File file, IProgressMonitor monitor) throws Exception;
|
||||
@@ -44,7 +46,7 @@ public interface ITaCoKitService {
|
||||
|
||||
boolean isTaCoKitType(Object repoType);
|
||||
|
||||
public static ITaCoKitService getInstance() throws Exception {
|
||||
public static ITaCoKitService getInstance() {
|
||||
BundleContext bc = FrameworkUtil.getBundle(ITaCoKitService.class).getBundleContext();
|
||||
Collection<ServiceReference<ITaCoKitService>> tacokitServices = Collections.emptyList();
|
||||
try {
|
||||
|
||||
@@ -29,6 +29,8 @@ public interface IExtendedList<T> extends List<T> {
|
||||
public void swapElements(List<Integer> indicesOrigin, List<Integer> indicesTarget);
|
||||
|
||||
public void swapElement(T object1, T object2);
|
||||
|
||||
public void replaceElement(int index, T object2);
|
||||
|
||||
/**
|
||||
* Getter for useEquals.
|
||||
|
||||
@@ -537,6 +537,11 @@ public class ListenableList<T> implements IExtendedList<T> {
|
||||
fireReplacedEvent(index, replacedObject, element, false);
|
||||
return replacedObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceElement(int index, T element) {
|
||||
this.list.set(index, element);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -66,10 +66,22 @@ public class NetworkUtil {
|
||||
|
||||
private static final String PROP_HTTP_PROXY_SET = "http.proxySet";
|
||||
|
||||
private static final String PROP_NETWORK_STATUS = "network.status"; //$NON-NLS-1$
|
||||
|
||||
public static boolean isNetworkValid() {
|
||||
return isNetworkValid(DEFAULT_TIMEOUT);
|
||||
}
|
||||
|
||||
public static boolean isNetworkValidByStatus() {
|
||||
String status = System.getProperty(PROP_NETWORK_STATUS);
|
||||
if (status != null) {
|
||||
return Boolean.valueOf(status);
|
||||
}
|
||||
Boolean isValid = isNetworkValid();
|
||||
System.setProperty(PROP_NETWORK_STATUS, isValid.toString());
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public static boolean isNetworkValid(Integer timeout) {
|
||||
String disableInternet = System.getProperty(TALEND_DISABLE_INTERNET);
|
||||
if ("true".equals(disableInternet)) { //$NON-NLS-1$
|
||||
|
||||
@@ -76,6 +76,8 @@ ExtendedTableMoveCommand.MoveLabel=Move up or down, one or more table entries
|
||||
ExtendedTablePasteCommand.Paste.Label=Paste data from the internal clipoard
|
||||
ExtendedTableRemoveCommand.Romve.Label=Remove table entries
|
||||
ExtendedTableResetDBTypesCommand.ResetDBTypes.Label=Reset all DB Types to get the defaults
|
||||
ExtendedTableCaseCommand.case.Label=Change selected DB columns to uppercase/lowercase
|
||||
ExtendedTableQuoteCommand.Quote.Label=Quote selected DB columns
|
||||
ImportPushButton.ImportButton.Tip=Replace all rows by import from xml file
|
||||
ImportPushButtonForExtendedTable.ErrorMsg.Text=Error occurred
|
||||
LabelledFileField.BrowseButton.Text=Browse...
|
||||
|
||||
@@ -27,11 +27,13 @@ import org.talend.commons.ui.swt.advanced.dataeditor.button.MoveDownPushButtonFo
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.MoveUpPushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.MoveUpPushButtonForExtendedTable;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.PastePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.QuotePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButtonForExtendedTable;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.ResetDBTypesPushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.SaveAsGenericSchemaPushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.SelectContextVariablesPushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.CasePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton;
|
||||
import org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer;
|
||||
|
||||
@@ -67,7 +69,11 @@ public class ExtendedToolbarView extends AbstractExtendedToolbar {
|
||||
protected ResetDBTypesPushButton resetDBTypesButton;
|
||||
|
||||
protected SelectContextVariablesPushButton selectContextVariablesButton;
|
||||
|
||||
protected CasePushButton caseButton;
|
||||
|
||||
protected QuotePushButton quoteButton;
|
||||
|
||||
/**
|
||||
* DOC amaumont MatadataToolbarEditor constructor comment.
|
||||
*
|
||||
@@ -103,7 +109,11 @@ public class ExtendedToolbarView extends AbstractExtendedToolbar {
|
||||
pasteButton = createPastePushButton();
|
||||
|
||||
addallButton = createAddAllPushButton();
|
||||
|
||||
|
||||
caseButton = createCasePushButton();
|
||||
|
||||
quoteButton = createQuotePushButton();
|
||||
|
||||
exportButton = createExportPushButton();
|
||||
|
||||
importButton = createImportPushButton();
|
||||
@@ -169,6 +179,14 @@ public class ExtendedToolbarView extends AbstractExtendedToolbar {
|
||||
protected SelectContextVariablesPushButton createSelectContextVariablesPushButton() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected CasePushButton createCasePushButton() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected QuotePushButton createQuotePushButton() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for addButton.
|
||||
@@ -327,6 +345,14 @@ public class ExtendedToolbarView extends AbstractExtendedToolbar {
|
||||
if (getAddallButton() != null) {
|
||||
list.add(getAddallButton());
|
||||
}
|
||||
|
||||
if (getCaseButton() != null) {
|
||||
list.add(getCaseButton());
|
||||
}
|
||||
|
||||
if (getQuoteButton() != null) {
|
||||
list.add(getQuoteButton());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -348,6 +374,26 @@ public class ExtendedToolbarView extends AbstractExtendedToolbar {
|
||||
public AddAllPushButton getAddallButton() {
|
||||
return this.addallButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for caseButton.
|
||||
*
|
||||
* @return the caseButton
|
||||
*/
|
||||
public CasePushButton getCaseButton() {
|
||||
return this.caseButton;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for quoteButton.
|
||||
*
|
||||
* @return the quoteButton
|
||||
*/
|
||||
public QuotePushButton getQuoteButton() {
|
||||
return this.quoteButton;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.swt.advanced.dataeditor.button;
|
||||
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.runtime.image.EImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton;
|
||||
import org.talend.commons.ui.swt.extended.table.AbstractExtendedControlViewer;
|
||||
|
||||
public abstract class CasePushButton extends ExtendedPushButton {
|
||||
|
||||
/**
|
||||
* DOC CasePushButton constructor comment.
|
||||
*
|
||||
* @param parent
|
||||
* @param extendedControlViewer
|
||||
*/
|
||||
public CasePushButton(Composite parent, AbstractExtendedControlViewer extendedControlViewer) {
|
||||
super(parent, extendedControlViewer,
|
||||
Messages.getString("CasePushButton.CaseButton.Tip"), ImageProvider.getImage(EImage.UPPERCASE_ICON)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
protected abstract Command getCommandToExecute();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton#getEnabledState()
|
||||
*/
|
||||
@Override
|
||||
public boolean getEnabledState() {
|
||||
return super.getEnabledState() && !getExtendedControlViewer().isReadOnly();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.swt.advanced.dataeditor.button;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.runtime.image.EImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer;
|
||||
import org.talend.commons.ui.swt.extended.table.ExtendedTableModel;
|
||||
|
||||
public abstract class CasePushButtonForExtendedTable extends CasePushButton implements IExtendedTablePushButton {
|
||||
|
||||
private EnableStateListenerForTableButton enableStateHandler;
|
||||
private boolean isUpperCase = true;
|
||||
|
||||
/**
|
||||
* DOC CasePushButtonForExtendedTable constructor comment.
|
||||
*
|
||||
* @param parent
|
||||
* @param extendedControlViewer
|
||||
*/
|
||||
public CasePushButtonForExtendedTable(Composite parent, AbstractExtendedTableViewer extendedTableViewer) {
|
||||
super(parent, extendedTableViewer);
|
||||
this.enableStateHandler = new EnableStateListenerForTableButton(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterCommandExecution(Command executedCommand) {
|
||||
super.afterCommandExecution(executedCommand);
|
||||
if (isUpperCase) {
|
||||
this.getButton().setToolTipText( Messages.getString("CasePushButton.CaseButton.Tip"));
|
||||
this.getButton().setImage(ImageProvider.getImage(EImage.LOWERCASE_ICON));
|
||||
this.isUpperCase = false;
|
||||
} else {
|
||||
this.getButton().setToolTipText( Messages.getString("CasePushButton.CaseButton.Tip"));
|
||||
this.getButton().setImage(ImageProvider.getImage(EImage.UPPERCASE_ICON));
|
||||
this.isUpperCase = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Command getCommandToExecute() {
|
||||
AbstractExtendedTableViewer extendedTableViewer = (AbstractExtendedTableViewer) extendedControlViewer;
|
||||
ExtendedTableModel extendedTableModel = extendedTableViewer.getExtendedTableModel();
|
||||
TableViewer tableViewer = extendedTableViewer.getTableViewerCreator().getTableViewer();
|
||||
ISelection selection = tableViewer.getSelection();
|
||||
StructuredSelection structuredSelection = (StructuredSelection) selection;
|
||||
Object[] objects = structuredSelection.toArray();
|
||||
int[] selectionIndices = extendedTableViewer.getTableViewerCreator().getTable().getSelectionIndices();
|
||||
return getCommandToExecute(extendedTableModel, Arrays.asList(objects), selectionIndices, isUpperCase);
|
||||
}
|
||||
|
||||
protected abstract Command getCommandToExecute(ExtendedTableModel extendedTable, List beansToUppercase, int[] selectionIndices, boolean isUpperCase);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.extended.button.IExtendedTablePushButton#getExtendedTableViewer()
|
||||
*/
|
||||
public AbstractExtendedTableViewer getExtendedTableViewer() {
|
||||
return (AbstractExtendedTableViewer) getExtendedControlViewer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnabledState() {
|
||||
return super.getEnabledState() && this.enableStateHandler.getEnabledState();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.swt.advanced.dataeditor.button;
|
||||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.runtime.image.EImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton;
|
||||
import org.talend.commons.ui.swt.extended.table.AbstractExtendedControlViewer;
|
||||
|
||||
public abstract class QuotePushButton extends ExtendedPushButton {
|
||||
|
||||
private String dbmsId = null;
|
||||
|
||||
/**
|
||||
* DOC QuotePushButton constructor comment.
|
||||
*
|
||||
* @param parent
|
||||
* @param extendedControlViewer
|
||||
*/
|
||||
public QuotePushButton(Composite parent, AbstractExtendedControlViewer extendedControlViewer) {
|
||||
super(parent, extendedControlViewer,
|
||||
Messages.getString("QuotePushButton.QuoteButton.Tip"), ImageProvider.getImage(EImage.EDIT_ICON)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton#getEnabledState()
|
||||
*/
|
||||
@Override
|
||||
public boolean getEnabledState() {
|
||||
return super.getEnabledState() && !getExtendedControlViewer().isReadOnly();
|
||||
}
|
||||
|
||||
|
||||
public String getDbmsId() {
|
||||
return dbmsId;
|
||||
}
|
||||
|
||||
|
||||
public void setDbmsId(String dbmsId) {
|
||||
this.dbmsId = dbmsId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.swt.advanced.dataeditor.button;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer;
|
||||
import org.talend.commons.ui.swt.extended.table.ExtendedTableModel;
|
||||
|
||||
public abstract class QuotePushButtonForExtendedTable extends QuotePushButton implements IExtendedTablePushButton {
|
||||
|
||||
private String quote = null;
|
||||
private boolean isAddingQuote = true;
|
||||
private EnableStateListenerForTableButton enableStateHandler;
|
||||
|
||||
/**
|
||||
* DOC SchemaTargetAddPushButton constructor comment.
|
||||
*
|
||||
* @param parent
|
||||
* @param extendedControlViewer
|
||||
*/
|
||||
public QuotePushButtonForExtendedTable(Composite parent, AbstractExtendedTableViewer extendedTableViewer) {
|
||||
super(parent, extendedTableViewer);
|
||||
this.enableStateHandler = new EnableStateListenerForTableButton(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton#beforeCommandExecution()
|
||||
*/
|
||||
@Override
|
||||
protected void beforeCommandExecution() {
|
||||
QuoteManipulateDialog dlg = new QuoteManipulateDialog(getButton().getShell());
|
||||
if (dlg.open() == Window.OK) {
|
||||
this.quote = dlg.getQuote();
|
||||
this.isAddingQuote = dlg.isAddingQuote();
|
||||
}
|
||||
}
|
||||
|
||||
protected Command getCommandToExecute() {
|
||||
if (quote == null) return null;
|
||||
AbstractExtendedTableViewer extendedTableViewer = (AbstractExtendedTableViewer) extendedControlViewer;
|
||||
ExtendedTableModel extendedTableModel = extendedTableViewer.getExtendedTableModel();
|
||||
TableViewer tableViewer = extendedTableViewer.getTableViewerCreator().getTableViewer();
|
||||
ISelection selection = tableViewer.getSelection();
|
||||
StructuredSelection structuredSelection = (StructuredSelection) selection;
|
||||
Object[] objects = structuredSelection.toArray();
|
||||
int[] selectionIndices = extendedTableViewer.getTableViewerCreator().getTable().getSelectionIndices();
|
||||
return getCommandToExecute(extendedTableModel, Arrays.asList(objects), selectionIndices, quote, isAddingQuote );
|
||||
}
|
||||
|
||||
protected abstract Command getCommandToExecute(ExtendedTableModel extendedTable, List beansToUppercase, int[] selectionIndices, String quote, boolean isAddingQuote);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.extended.button.IExtendedTablePushButton#getExtendedTableViewer()
|
||||
*/
|
||||
public AbstractExtendedTableViewer getExtendedTableViewer() {
|
||||
return (AbstractExtendedTableViewer) getExtendedControlViewer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnabledState() {
|
||||
return super.getEnabledState() && this.enableStateHandler.getEnabledState();
|
||||
}
|
||||
|
||||
class QuoteManipulateDialog extends Dialog {
|
||||
|
||||
private Button addBtn;
|
||||
private Button removeBtn;
|
||||
private Text quoteTxt;
|
||||
private Button okBtn;
|
||||
boolean isAddingQuote = true;
|
||||
String quote = "";
|
||||
|
||||
public QuoteManipulateDialog(Shell parentShel) {
|
||||
super(parentShel);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
protected void configureShell(Shell shell) {
|
||||
super.configureShell(shell);
|
||||
shell.setText(Messages.getString("QuoteManipulateDialog.title"));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
// create OK and Cancel buttons by default
|
||||
okBtn = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
|
||||
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
|
||||
okBtn.setEnabled(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc) Method declared on Dialog.
|
||||
*/
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 4;
|
||||
composite.setLayout(layout);
|
||||
GridData layoutData = new GridData(GridData.FILL_BOTH);
|
||||
layoutData.widthHint = 400;
|
||||
composite.setLayoutData(layoutData);
|
||||
addBtn = new Button(composite, SWT.RADIO);
|
||||
addBtn.setSelection(true);
|
||||
Label label = new Label(composite, SWT.WRAP);
|
||||
label.setText(Messages.getString("QuoteManipulateDialog.addQuote")); //$NON-NLS-1$
|
||||
|
||||
removeBtn = new Button(composite, SWT.RADIO);
|
||||
Label label1 = new Label(composite, SWT.WRAP);
|
||||
label1.setText(Messages.getString("QuoteManipulateDialog.removeQuote")); //$NON-NLS-1$
|
||||
|
||||
quoteTxt = new Text(composite, SWT.SINGLE | SWT.BORDER);
|
||||
layoutData = new GridData(GridData.FILL_HORIZONTAL);
|
||||
layoutData.horizontalSpan = 4;
|
||||
quoteTxt.setLayoutData(layoutData);
|
||||
quoteTxt.setText("");
|
||||
quoteTxt.setFocus();
|
||||
|
||||
addBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
isAddingQuote = true;
|
||||
quoteTxt.setFocus();
|
||||
quote = quoteTxt.getText();
|
||||
}
|
||||
});
|
||||
|
||||
removeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
isAddingQuote = false;
|
||||
quoteTxt.setFocus();
|
||||
quote = quoteTxt.getText();
|
||||
}
|
||||
});
|
||||
|
||||
quoteTxt.addModifyListener(new ModifyListener() {
|
||||
|
||||
public void modifyText(ModifyEvent e) {
|
||||
quote = quoteTxt.getText();
|
||||
if ( quote != null && quote.length() > 0) {
|
||||
okBtn.setEnabled(true);
|
||||
} else {
|
||||
okBtn.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
public boolean isAddingQuote() {
|
||||
return this.isAddingQuote;
|
||||
}
|
||||
|
||||
public String getQuote() {
|
||||
return this.quote;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.swt.advanced.dataeditor.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.swt.extended.table.ExtendedTableModel;
|
||||
|
||||
public abstract class ExtendedTableCaseCommand extends Command implements IExtendedTableCommand {
|
||||
|
||||
private ExtendedTableModel extendedTable;
|
||||
|
||||
private List beansToCovertCase;
|
||||
|
||||
private int[] selectionIndices;
|
||||
|
||||
private boolean isUpperCase;
|
||||
|
||||
|
||||
public static final String LABEL = Messages.getString("ExtendedTableCaseCommand.case.Label"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* DOC ExtendedTableCaseCommand constructor comment.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")//$NON-NLS-1$
|
||||
public ExtendedTableCaseCommand(ExtendedTableModel extendedTable, List beansToCovertCase, int[] selectionIndices, boolean isUpperCase) {
|
||||
super(LABEL);
|
||||
this.extendedTable = extendedTable;
|
||||
this.beansToCovertCase = new ArrayList(beansToCovertCase);
|
||||
this.selectionIndices = selectionIndices;
|
||||
this.isUpperCase = isUpperCase;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.gef.commands.Command#execute()
|
||||
*/
|
||||
@Override
|
||||
public void execute() {
|
||||
convertCase(extendedTable, beansToCovertCase, selectionIndices, isUpperCase);
|
||||
|
||||
}
|
||||
|
||||
public abstract void convertCase(ExtendedTableModel extendedTable, List copiedObjectsList, int[] selectionIndices, boolean isUpperCase);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.ui.command.CommonCommand#canUndo()
|
||||
*/
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.ui.command.CommonCommand#redo()
|
||||
*/
|
||||
@Override
|
||||
public void redo() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.ui.command.CommonCommand#undo()
|
||||
*/
|
||||
@Override
|
||||
public void undo() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.swt.advanced.dataeditor.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.swt.extended.table.ExtendedTableModel;
|
||||
|
||||
public abstract class ExtendedTableQuoteCommand extends Command implements IExtendedTableCommand {
|
||||
|
||||
private ExtendedTableModel extendedTable;
|
||||
|
||||
private List beansToQuote;
|
||||
|
||||
private int[] selectionIndices;
|
||||
|
||||
private String quote;
|
||||
|
||||
boolean isAddingQuote;
|
||||
|
||||
|
||||
public static final String LABEL = Messages.getString("ExtendedTableQuoteCommand.Quote.Label"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* DOC ExtendedTableQuoteCommand constructor comment.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")//$NON-NLS-1$
|
||||
public ExtendedTableQuoteCommand(ExtendedTableModel extendedTable, List beansToQuote, int[] selectionIndices, String quote, boolean isAddingQuote) {
|
||||
super(LABEL);
|
||||
this.extendedTable = extendedTable;
|
||||
this.beansToQuote = new ArrayList(beansToQuote);
|
||||
this.selectionIndices = selectionIndices;
|
||||
this.quote = quote;
|
||||
this.isAddingQuote = isAddingQuote;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.gef.commands.Command#execute()
|
||||
*/
|
||||
@Override
|
||||
public void execute() {
|
||||
toQuote(extendedTable, beansToQuote, selectionIndices, quote, isAddingQuote);
|
||||
|
||||
}
|
||||
|
||||
public abstract void toQuote(ExtendedTableModel extendedTable, List copiedObjectsList, int[] selectionIndices, String quote, boolean isAddingQuote);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.ui.command.CommonCommand#canUndo()
|
||||
*/
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.ui.command.CommonCommand#redo()
|
||||
*/
|
||||
@Override
|
||||
public void redo() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.ui.command.CommonCommand#undo()
|
||||
*/
|
||||
@Override
|
||||
public void undo() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,12 +15,12 @@ package org.talend.commons.ui.swt.colorstyledtext.rules;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.text.rules.ICharacterScanner;
|
||||
import org.eclipse.jface.text.rules.IRule;
|
||||
import org.eclipse.jface.text.rules.IToken;
|
||||
import org.eclipse.jface.text.rules.IWordDetector;
|
||||
import org.eclipse.jface.text.rules.Token;
|
||||
import org.eclipse.jface.util.Assert;
|
||||
|
||||
/**
|
||||
* An implementation of <code>IRule</code> capable of detecting words Word rules also allow for the association of
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.swt.colorstyledtext.rules;
|
||||
|
||||
import org.eclipse.jface.util.Assert;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.jedit.Rule;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.jedit.Type;
|
||||
|
||||
|
||||
@@ -178,6 +178,23 @@ public class ExtendedTableModel<B> extends AbstractExtendedControlModel {
|
||||
public void setUseEquals(boolean useEquals) {
|
||||
beansList.setUseEquals(useEquals);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Replace bean.
|
||||
*
|
||||
* @param bean
|
||||
* @param index can be null
|
||||
*/
|
||||
public void replace(B bean, Integer index) {
|
||||
|
||||
if (tableViewer != null && !tableViewer.getTable().isDisposed()) {
|
||||
tableViewer.replace(bean, index);
|
||||
tableViewer.refresh(bean, true, true);
|
||||
}
|
||||
this.beansList.replaceElement(index, bean);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DOC amaumont Comment method "remove".
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.apache.oro.text.regex.PatternCompiler;
|
||||
import org.apache.oro.text.regex.PatternMatcher;
|
||||
import org.apache.oro.text.regex.Perl5Compiler;
|
||||
import org.apache.oro.text.regex.Perl5Matcher;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.ListenerList;
|
||||
import org.eclipse.jface.bindings.keys.KeyStroke;
|
||||
import org.eclipse.jface.dialogs.PopupDialog;
|
||||
@@ -34,7 +35,6 @@ import org.eclipse.jface.fieldassist.IContentProposal;
|
||||
import org.eclipse.jface.fieldassist.IContentProposalListener;
|
||||
import org.eclipse.jface.fieldassist.IContentProposalProvider;
|
||||
import org.eclipse.jface.fieldassist.IControlContentAdapter;
|
||||
import org.eclipse.jface.util.Assert;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.utils.data.text.rules;
|
||||
|
||||
import org.eclipse.jface.text.Assert;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.text.rules.ICharacterScanner;
|
||||
import org.eclipse.jface.text.rules.IPredicateRule;
|
||||
import org.eclipse.jface.text.rules.IRule;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.utils.workbench.preferences;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.preference.FieldEditor;
|
||||
import org.eclipse.jface.util.Assert;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
||||
@@ -23,8 +23,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.PredicateUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.ISafeRunnable;
|
||||
@@ -95,6 +93,7 @@ import org.talend.core.repository.model.repositoryObject.SalesforceModuleReposit
|
||||
import org.talend.core.repository.recyclebin.RecycleBinManager;
|
||||
import org.talend.core.repository.ui.utils.ProjectRepositoryNodeCache;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.core.runtime.services.IGenericService;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.core.ui.ICDCProviderService;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
@@ -392,10 +391,7 @@ public class ProjectRepositoryNode extends RepositoryNode implements IProjectRep
|
||||
}
|
||||
|
||||
private void initNodesFromComponentSerivice(RepositoryNode curParentNode) {
|
||||
IGenericWizardService wizardService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
wizardService = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
|
||||
}
|
||||
IGenericService wizardService = IGenericService.getService();
|
||||
if (wizardService != null) {
|
||||
List<RepositoryNode> nodes = wizardService.createNodesFromComponentService(curParentNode);
|
||||
for (RepositoryNode repNode : nodes) {
|
||||
|
||||
@@ -40,10 +40,12 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
@@ -70,8 +72,10 @@ import org.talend.commons.exception.SystemException;
|
||||
import org.talend.commons.runtime.model.repository.ERepositoryStatus;
|
||||
import org.talend.commons.runtime.service.ITaCoKitService;
|
||||
import org.talend.commons.ui.gmf.util.DisplayUtils;
|
||||
import org.talend.commons.ui.runtime.CommonUIPlugin;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
import org.talend.commons.utils.data.container.RootContainer;
|
||||
import org.talend.commons.utils.generation.JavaUtils;
|
||||
import org.talend.commons.utils.network.TalendProxySelector;
|
||||
import org.talend.commons.utils.time.TimeMeasurePerformance;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
@@ -85,7 +89,8 @@ import org.talend.core.context.CommandLineContext;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.exception.TalendInternalPersistenceException;
|
||||
import org.talend.core.hadoop.BigDataBasicUtil;
|
||||
import org.talend.core.hadoop.IHadoopDistributionService;
|
||||
import org.talend.core.model.components.IComponentsService;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
@@ -134,10 +139,12 @@ import org.talend.core.repository.utils.ProjectDataJsonProvider;
|
||||
import org.talend.core.repository.utils.RepositoryPathProvider;
|
||||
import org.talend.core.repository.utils.XmiResourceManager;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.hd.IDynamicDistributionManager;
|
||||
import org.talend.core.runtime.repository.item.ItemProductKeys;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.core.runtime.services.IMavenUIService;
|
||||
import org.talend.core.runtime.util.ItemDateParser;
|
||||
import org.talend.core.runtime.util.JavaHomeUtil;
|
||||
import org.talend.core.runtime.util.SharedStudioUtils;
|
||||
import org.talend.core.service.ICoreUIService;
|
||||
import org.talend.core.utils.CodesJarResourceCache;
|
||||
@@ -2191,9 +2198,6 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
// init dynamic distirbution after `beforeLogon`, before loading libraries.
|
||||
initDynamicDistribution(monitor);
|
||||
|
||||
// init sdk component
|
||||
try {
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
@@ -2224,6 +2228,14 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
}
|
||||
}
|
||||
|
||||
if (CommonsPlugin.isJUnitTest() || PluginChecker.isSWTBotLoaded()) {
|
||||
// component init for cmdline is done in another place
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.load.componnents"), 1); //$NON-NLS-1$
|
||||
IComponentsService.get().getComponentsFactory().getComponents();
|
||||
TimeMeasurePerformance.step("logOnProject", "Initialize components"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
ICoreService coreService = getCoreService();
|
||||
if (coreService != null) {
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
@@ -2240,8 +2252,6 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
CodesJarResourceCache.initCodesJarCache();
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask("Execute before logon migrations tasks", 1); //$NON-NLS-1$
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
@@ -2260,15 +2270,10 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
|
||||
emptyTempFolder(project);
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.load.componnents"), 1); //$NON-NLS-1$
|
||||
ICoreUIService coreUiService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreUIService.class)) {
|
||||
coreUiService = GlobalServiceRegister.getDefault().getService(ICoreUIService.class);
|
||||
}
|
||||
if (coreUiService != null) {
|
||||
coreUiService.componentsReset();
|
||||
}
|
||||
|
||||
fireRepositoryPropertyChange(ERepositoryActionName.PROJECT_PREFERENCES_RELOAD.getName(), null, null);
|
||||
|
||||
@@ -2295,6 +2300,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
}
|
||||
|
||||
if (coreService != null) {
|
||||
updateProjectJavaVersionIfNeed();
|
||||
// clean workspace
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.cleanWorkspace"), 1); //$NON-NLS-1$
|
||||
|
||||
@@ -2309,27 +2315,13 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.synch.repo.items"), 1); //$NON-NLS-1$
|
||||
|
||||
if (!isCommandLineLocalRefProject) {
|
||||
try {
|
||||
coreService.syncAllRoutines();
|
||||
// PTODO need refactor later, this is not good, I think
|
||||
coreService.syncAllBeans();
|
||||
} catch (SystemException e1) {
|
||||
//
|
||||
ExceptionHandler.process(e1);
|
||||
}
|
||||
syncAndInstallCodes(currentMonitor);
|
||||
}
|
||||
}
|
||||
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
// rules
|
||||
if (coreUiService != null && PluginChecker.isRulesPluginLoaded()) {
|
||||
coreUiService.syncAllRules();
|
||||
}
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
TimeMeasurePerformance.step("logOnProject", "sync repository (routines/rules/beans)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// log4j prefs
|
||||
if (coreUiService != null && coreService != null) {
|
||||
@@ -2348,11 +2340,6 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
if (runProcessService != null && !isCommandLineLocalRefProject) {
|
||||
runProcessService.initializeRootPoms(monitor);
|
||||
|
||||
TimeMeasurePerformance.step("logOnProject", "install / setup root poms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
|
||||
ITDQRepositoryService tdqRepositoryService = GlobalServiceRegister.getDefault()
|
||||
.getService(ITDQRepositoryService.class);
|
||||
@@ -2360,8 +2347,10 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
tdqRepositoryService.initProxyRepository();
|
||||
}
|
||||
}
|
||||
// regenerate relationship index
|
||||
if (project.getEmfProject().getItemsRelations().isEmpty()) {
|
||||
// regenerate relationship index if error index found
|
||||
try {
|
||||
ProjectDataJsonProvider.checkRelationShipSetting(project.getEmfProject());
|
||||
} catch (Exception e) {
|
||||
RelationshipItemBuilder.getInstance().buildAndSaveIndex();
|
||||
}
|
||||
|
||||
@@ -2386,16 +2375,67 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void initDynamicDistribution(IProgressMonitor monitor) {
|
||||
|
||||
private void updateProjectJavaVersionIfNeed() {
|
||||
String specifiedVersion = null;
|
||||
String currentVersion = JavaUtils.getProjectJavaVersion();
|
||||
String newVersion = null;
|
||||
try {
|
||||
if (BigDataBasicUtil.isDynamicDistributionLoaded(monitor)) {
|
||||
BigDataBasicUtil.reloadAllDynamicDistributions(monitor);
|
||||
} else {
|
||||
BigDataBasicUtil.loadDynamicDistribution(monitor);
|
||||
JavaHomeUtil.initializeJavaHome();
|
||||
} catch (CoreException ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
if (CommonUIPlugin.isFullyHeadless()) {
|
||||
specifiedVersion = JavaHomeUtil.getSpecifiedJavaVersion();
|
||||
}
|
||||
if (specifiedVersion == null) {
|
||||
newVersion = currentVersion != null ? currentVersion : JavaUtils.DEFAULT_VERSION;
|
||||
} else {
|
||||
newVersion = specifiedVersion;
|
||||
}
|
||||
|
||||
JavaUtils.updateProjectJavaVersion(newVersion);
|
||||
}
|
||||
|
||||
private void syncAndInstallCodes(IProgressMonitor monitor) {
|
||||
if (CommonsPlugin.isHeadless() || CommonsPlugin.isJUnitTest() || PluginChecker.isSWTBotLoaded()) {
|
||||
try {
|
||||
doSyncAndInstallCodes(monitor);
|
||||
} catch (SystemException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
} else {
|
||||
Job job = new Job("Synchronize and install codes") {
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
doSyncAndInstallCodes(monitor);
|
||||
return org.eclipse.core.runtime.Status.OK_STATUS;
|
||||
} catch (Exception e) {
|
||||
return new org.eclipse.core.runtime.Status(IStatus.ERROR, CoreRepositoryPlugin.PLUGIN_ID, 1,
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
job.setUser(false);
|
||||
job.setPriority(Job.LONG);
|
||||
job.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
private void doSyncAndInstallCodes(IProgressMonitor monitor) throws SystemException {
|
||||
ICoreService coreService = getCoreService();
|
||||
if (coreService != null) {
|
||||
CodesJarResourceCache.reset();
|
||||
coreService.syncAllRoutines();
|
||||
coreService.syncAllBeans();
|
||||
TimeMeasurePerformance.step("logOnProject", "sync repository (routines/beans)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
if (IRunProcessService.get() != null) {
|
||||
IRunProcessService.get().initializeRootPoms(monitor);
|
||||
TimeMeasurePerformance.step("logOnProject", "install / setup root poms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2456,6 +2496,25 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
if (runProcessService != null) {
|
||||
runProcessService.clearProjectRelatedSettings();
|
||||
}
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreUIService.class)) {
|
||||
ICoreUIService coreUiService = GlobalServiceRegister.getDefault().getService(ICoreUIService.class);
|
||||
if (coreUiService != null) {
|
||||
coreUiService.componentsReset();
|
||||
}
|
||||
}
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopDistributionService.class)) {
|
||||
IHadoopDistributionService hdService = GlobalServiceRegister.getDefault()
|
||||
.getService(IHadoopDistributionService.class);
|
||||
if (hdService != null) {
|
||||
IDynamicDistributionManager dynamicDistrManager = hdService.getDynamicDistributionManager();
|
||||
dynamicDistrManager.reset(null);
|
||||
}
|
||||
}
|
||||
|
||||
CodesJarResourceCache.reset();
|
||||
|
||||
ReferenceProjectProvider.clearTacReferenceList();
|
||||
ReferenceProjectProblemManager.getInstance().clearAll();
|
||||
fullLogonFinished = false;
|
||||
@@ -2774,7 +2833,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
ILoginTask[] allLoginTasks = LOGIN_TASK_REGISTRY_READER.getAllTaskListInstance();
|
||||
for (ILoginTask task : allLoginTasks) {
|
||||
if (task.isRequiredAlways()) {
|
||||
task.run(monitor);
|
||||
task.execute(monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,14 +224,15 @@ public class ProjectDataJsonProvider {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ItemRelationsJson> checkRelationShipSetting(Project project) throws PersistenceException {
|
||||
List<ItemRelationsJson> itemRelationsJsonsList = null;
|
||||
|
||||
public static void checkAndRectifyRelationShipSetting(Project project) throws PersistenceException {
|
||||
File file = getSavingConfigurationFile(project.getTechnicalLabel(), FileConstants.RELATIONSHIP_FILE_NAME);
|
||||
if (file == null || !file.exists()) {
|
||||
return;
|
||||
return itemRelationsJsonsList;
|
||||
}
|
||||
|
||||
List<ItemRelationsJson> itemRelationsJsonsList = null;
|
||||
TypeReference<List<ItemRelationsJson>> typeReference = new TypeReference<List<ItemRelationsJson>>() {
|
||||
};
|
||||
FileInputStream input = null;
|
||||
@@ -243,6 +244,11 @@ public class ProjectDataJsonProvider {
|
||||
} finally {
|
||||
closeInputStream(input);
|
||||
}
|
||||
return itemRelationsJsonsList;
|
||||
}
|
||||
|
||||
public static void checkAndRectifyRelationShipSetting(Project project) throws PersistenceException {
|
||||
List<ItemRelationsJson> itemRelationsJsonsList = checkRelationShipSetting(project);
|
||||
|
||||
if (itemRelationsJsonsList == null || itemRelationsJsonsList.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -40,8 +40,6 @@ public interface ILibraryManagerService extends IService {
|
||||
*/
|
||||
public boolean isInitialized();
|
||||
|
||||
public void setInitialized();
|
||||
|
||||
public void installModules(Collection<ModuleNeeded> modules, IProgressMonitor monitorWrap);
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.database.conn.ConnParameterKeys;
|
||||
import org.talend.core.database.conn.template.DbConnStrForHive;
|
||||
import org.talend.core.hadoop.BigDataBasicUtil;
|
||||
import org.talend.core.hadoop.IHadoopDistributionService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
@@ -82,7 +83,7 @@ public class ClassLoaderFactory {
|
||||
}
|
||||
|
||||
public static DynamicClassLoader getClassLoader(String index, boolean showDownloadIfNotExist) {
|
||||
DynamicClassLoader classLoader = getClassLoaderMap().get(index);
|
||||
DynamicClassLoader classLoader = getClassLoaderMap(index).get(index);
|
||||
if (classLoader == null) {
|
||||
classLoader = findLoader(index, null, showDownloadIfNotExist);
|
||||
}
|
||||
@@ -91,7 +92,7 @@ public class ClassLoaderFactory {
|
||||
}
|
||||
|
||||
public static DynamicClassLoader getClassLoader(String index, ClassLoader parentClassLoader) {
|
||||
DynamicClassLoader classLoader = getClassLoaderMap().get(index);
|
||||
DynamicClassLoader classLoader = getClassLoaderMap(index).get(index);
|
||||
if (classLoader == null) {
|
||||
classLoader = findLoader(index, parentClassLoader, true);
|
||||
}
|
||||
@@ -154,12 +155,12 @@ public class ClassLoaderFactory {
|
||||
private static DynamicClassLoader createCustomClassLoader(String index, Set<String> libraries) {
|
||||
DynamicClassLoader classLoader = new DynamicClassLoader();
|
||||
loadLibraries(classLoader, libraries.toArray(new String[0]), true);
|
||||
getClassLoaderMap().put(index, classLoader);
|
||||
getClassLoaderMap(index).put(index, classLoader);
|
||||
|
||||
return classLoader;
|
||||
}
|
||||
|
||||
private static void init() {
|
||||
private static void init(String index) {
|
||||
File tmpFolder = getTmpFolder();
|
||||
if (tmpFolder.exists()) {
|
||||
FilesUtils.removeFolder(tmpFolder, true);
|
||||
@@ -168,7 +169,7 @@ public class ClassLoaderFactory {
|
||||
}
|
||||
|
||||
public static IConfigurationElement findIndex(String index) {
|
||||
IConfigurationElement[] elements = getConfigurationElements();
|
||||
IConfigurationElement[] elements = getConfigurationElements(index);
|
||||
if (StringUtils.isNotEmpty(index) && elements != null) {
|
||||
for (IConfigurationElement current : elements) {
|
||||
String key = current.getAttribute(INDEX_ATTR);
|
||||
@@ -225,7 +226,7 @@ public class ClassLoaderFactory {
|
||||
}
|
||||
if (putInCache) {
|
||||
// if any libraries can't be retreived , do not put it in cache
|
||||
getClassLoaderMap().put(index, classLoader);
|
||||
getClassLoaderMap(index).put(index, classLoader);
|
||||
}
|
||||
return classLoader;
|
||||
}
|
||||
@@ -337,7 +338,7 @@ public class ClassLoaderFactory {
|
||||
}
|
||||
|
||||
public static String[] getDriverModuleList(String connKeyString) {
|
||||
IConfigurationElement[] elements = getConfigurationElements();
|
||||
IConfigurationElement[] elements = getConfigurationElements(connKeyString);
|
||||
if (connKeyString != null && elements != null) {
|
||||
for (IConfigurationElement current : elements) {
|
||||
String key = current.getAttribute(INDEX_ATTR);
|
||||
@@ -365,12 +366,36 @@ public class ClassLoaderFactory {
|
||||
return hdClassLoader;
|
||||
}
|
||||
|
||||
private static IConfigurationElement[] getConfigurationElements() {
|
||||
checkCache();
|
||||
private static IConfigurationElement[] getConfigurationElements(String index) {
|
||||
checkCache(index);
|
||||
return configurationElements;
|
||||
}
|
||||
|
||||
private synchronized static void checkCache() {
|
||||
private static String getVersion(String index) {
|
||||
if (StringUtils.isBlank(index)) {
|
||||
return null;
|
||||
}
|
||||
String[] split = index.split(":");
|
||||
if (2 < split.length) {
|
||||
return split[2];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized static void checkCache(String index) {
|
||||
try {
|
||||
String version = getVersion(index);
|
||||
if (StringUtils.isNotBlank(version)) {
|
||||
IHadoopDistributionService hdService = IHadoopDistributionService.get();
|
||||
if (hdService != null) {
|
||||
hdService.checkDynamicDistributionExtensions(version);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
boolean isCacheChanged = false;
|
||||
if (configurationElements != null) {
|
||||
for (IConfigurationElement configElement : configurationElements) {
|
||||
@@ -379,17 +404,17 @@ public class ClassLoaderFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!StringUtils.equals(cacheVersion, BigDataBasicUtil.getDynamicDistributionCacheVersion())) {
|
||||
if (!StringUtils.equals(cacheVersion, BigDataBasicUtil.getDynamicDistributionPluginExtensionCacheVersion())) {
|
||||
isCacheChanged = true;
|
||||
}
|
||||
if (isCacheChanged) {
|
||||
init();
|
||||
init(index);
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
configurationElements = registry.getConfigurationElementsFor(EXTENSION_POINT_ID);
|
||||
cacheVersion = BigDataBasicUtil.getDynamicDistributionCacheVersion();
|
||||
cacheVersion = BigDataBasicUtil.getDynamicDistributionPluginExtensionCacheVersion();
|
||||
} else {
|
||||
if (classLoadersMap == null) {
|
||||
init();
|
||||
init(index);
|
||||
}
|
||||
if (configurationElements == null) {
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
@@ -398,8 +423,8 @@ public class ClassLoaderFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, DynamicClassLoader> getClassLoaderMap() {
|
||||
checkCache();
|
||||
private static Map<String, DynamicClassLoader> getClassLoaderMap(String index) {
|
||||
checkCache(index);
|
||||
return classLoadersMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,7 @@ public interface DownloadListener {
|
||||
* Notify after download complete.
|
||||
*/
|
||||
void downloadComplete();
|
||||
|
||||
|
||||
default void downloadFailed(Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,5 +24,13 @@ public interface IDownloadHelper {
|
||||
public void setCancel(boolean cancel);
|
||||
|
||||
public void download(URL componentUrl, File destination) throws Exception;
|
||||
|
||||
default URL getDownloadingURL() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default long getContentLength() {
|
||||
return -1l;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -132,4 +132,17 @@ public class BigDataBasicUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getDynamicDistributionPluginExtensionCacheVersion() {
|
||||
try {
|
||||
IDynamicDistributionManager ddManager = getDynamicDistributionManager(new NullProgressMonitor());
|
||||
if (ddManager != null && ddManager.isLoaded()) {
|
||||
return ddManager.getPluginExtensionCacheVersion();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ package org.talend.core.hadoop;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.runtime.hd.IDistributionsManager;
|
||||
import org.talend.core.runtime.hd.IDynamicDistributionManager;
|
||||
@@ -64,6 +65,8 @@ public interface IHadoopDistributionService extends IService {
|
||||
*/
|
||||
IHDistributionVersion getHadoopDistributionVersion(String version, boolean byDisplay);
|
||||
|
||||
boolean checkDynamicDistributionExtensions(String version);
|
||||
|
||||
/**
|
||||
*
|
||||
* for Hadoop Distribution {@link HadoopComponent}.
|
||||
@@ -128,4 +131,13 @@ public interface IHadoopDistributionService extends IService {
|
||||
boolean doSupportMapRTicket(IHDistributionVersion distributionVersion);
|
||||
|
||||
IDynamicDistributionManager getDynamicDistributionManager();
|
||||
|
||||
public static IHadoopDistributionService get() {
|
||||
GlobalServiceRegister gsr = GlobalServiceRegister.getDefault();
|
||||
if (gsr.isServiceRegistered(IHadoopDistributionService.class)) {
|
||||
return gsr.getService(IHadoopDistributionService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,89 +12,126 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.model.components;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.emf.ecore.xmi.XMLResource;
|
||||
import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.runtime.model.emf.EmfHelper;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.language.LanguageManager;
|
||||
import org.talend.core.model.component_cache.ComponentCacheFactory;
|
||||
import org.talend.core.model.component_cache.ComponentCachePackage;
|
||||
import org.talend.core.model.component_cache.ComponentsCache;
|
||||
import org.talend.core.model.component_cache.util.ComponentCacheResourceFactoryImpl;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.utils.TalendCacheUtils;
|
||||
|
||||
/**
|
||||
* DOC zwzhao class global comment. Detailled comment
|
||||
*/
|
||||
public class ComponentManager {
|
||||
|
||||
private static ComponentsCache cache;
|
||||
private static final String TALEND_COMPONENTS_CACHE_FILE = "components.cache"; //$NON-NLS-1$
|
||||
|
||||
private static final String TALEND_COMPONENT_CACHE = "ComponentsCache.";
|
||||
private static Map<String, ComponentsCache> caches = new HashMap<>();
|
||||
|
||||
private static final String TALEND_FILE_NAME = "cache";
|
||||
private static Set<File> providerInstallationFolders;
|
||||
|
||||
private static boolean modified = false;
|
||||
private static Set<String> modified = new HashSet<>();
|
||||
|
||||
public static ComponentsCache getComponentCache() {
|
||||
if (cache == null) {
|
||||
cache = ComponentCacheFactory.eINSTANCE.createComponentsCache();
|
||||
public static Map<String, ComponentsCache> getComponentCaches() {
|
||||
if (caches.isEmpty()) {
|
||||
getProviderInstallationFolders()
|
||||
.forEach(f -> caches.put(f.getAbsolutePath(), ComponentCacheFactory.eINSTANCE.createComponentsCache()));
|
||||
}
|
||||
return cache;
|
||||
return caches;
|
||||
}
|
||||
|
||||
public static void saveResource() {
|
||||
if (isModified()) {
|
||||
String installLocation = new Path(Platform.getConfigurationLocation().getURL().getPath()).toFile().getAbsolutePath();
|
||||
try {
|
||||
Resource resource = createComponentCacheResource(installLocation);
|
||||
resource.getContents().add(cache);
|
||||
EmfHelper.saveResource(cache.eResource());
|
||||
} catch (PersistenceException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
}
|
||||
ILibraryManagerService repositoryBundleService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
if (!modified.isEmpty()) {
|
||||
caches.entrySet().stream().filter(entry -> modified.contains(entry.getKey())).forEach(entry -> {
|
||||
try {
|
||||
Resource resource = createComponentCacheResource(entry.getKey());
|
||||
resource.getContents().add(entry.getValue());
|
||||
EmfHelper.saveResource(entry.getValue().eResource());
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
});
|
||||
ILibraryManagerService repositoryBundleService = GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
repositoryBundleService.clearCache();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
ILibrariesService libService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibrariesService.class);
|
||||
if (libService != null) {
|
||||
libService.syncLibraries();
|
||||
}
|
||||
}
|
||||
setModified(false);
|
||||
modified.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static Resource createComponentCacheResource(String installLocation) {
|
||||
String filePath = ComponentManager.TALEND_COMPONENT_CACHE + LanguageManager.getCurrentLanguage().toString().toLowerCase()
|
||||
+ ComponentManager.TALEND_FILE_NAME;
|
||||
URI uri = URI.createFileURI(installLocation).appendSegment(filePath);
|
||||
public static boolean needRegenerateCache(String installLocation) {
|
||||
// if there is no index file or -clean is added to command
|
||||
return !hasComponentFile(installLocation) || TalendCacheUtils.isSetCleanComponentCache();
|
||||
}
|
||||
|
||||
public static boolean hasComponentFile(String installLocation) {
|
||||
File file = new File(installLocation, TALEND_COMPONENTS_CACHE_FILE);
|
||||
return file != null && file.exists();
|
||||
}
|
||||
|
||||
public static void loadComponentResource() throws IOException {
|
||||
caches.clear();
|
||||
for (File installationFolder : getProviderInstallationFolders()) {
|
||||
URI uri = URI.createFileURI(installationFolder.getAbsolutePath()).appendSegment(TALEND_COMPONENTS_CACHE_FILE);
|
||||
ComponentCacheResourceFactoryImpl compFact = new ComponentCacheResourceFactoryImpl();
|
||||
Resource resource = compFact.createResource(uri);
|
||||
Map<Object, Object> optionMap = new HashMap<>();
|
||||
optionMap.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
|
||||
optionMap.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
|
||||
optionMap.put(XMLResource.OPTION_USE_PARSER_POOL, new XMLParserPoolImpl());
|
||||
optionMap.put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, new HashMap<>());
|
||||
optionMap.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE);
|
||||
|
||||
// TODO remove the try catch block after merge commits for TDM
|
||||
try {
|
||||
resource.load(optionMap);
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
continue;
|
||||
}
|
||||
caches.put(installationFolder.getAbsolutePath(), (ComponentsCache) EcoreUtil.getObjectByType(resource.getContents(),
|
||||
ComponentCachePackage.eINSTANCE.getComponentsCache()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearAllCaches() {
|
||||
caches.clear();
|
||||
}
|
||||
|
||||
public static void setModified(String installationFolder) {
|
||||
modified.add(installationFolder);
|
||||
}
|
||||
|
||||
private static Resource createComponentCacheResource(String installLocation) {
|
||||
URI uri = URI.createFileURI(installLocation).appendSegment(TALEND_COMPONENTS_CACHE_FILE);
|
||||
ComponentCacheResourceFactoryImpl compFact = new ComponentCacheResourceFactoryImpl();
|
||||
return compFact.createResource(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for modified.
|
||||
*
|
||||
* @return the modified
|
||||
*/
|
||||
public static boolean isModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the modified.
|
||||
*
|
||||
* @param modified the modified to set
|
||||
*/
|
||||
public static void setModified(boolean modified) {
|
||||
ComponentManager.modified = modified;
|
||||
private static Set<File> getProviderInstallationFolders() {
|
||||
if (providerInstallationFolders == null && IComponentsService.get() != null) {
|
||||
providerInstallationFolders = IComponentsService.get().getComponentsFactory().getProviderInstallationFolders();
|
||||
}
|
||||
if (providerInstallationFolders == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return providerInstallationFolders;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public interface IComponentsFactory {
|
||||
*/
|
||||
public Set<IComponent> getComponents();
|
||||
|
||||
public boolean isInitialising();
|
||||
public boolean isInitializing();
|
||||
|
||||
/**
|
||||
* Get a readonly components collection to avoid ConcurrentModificationException caused by multiple thread
|
||||
@@ -113,4 +113,9 @@ public interface IComponentsFactory {
|
||||
public List<ComponentProviderInfo> getComponentsProvidersInfo();
|
||||
|
||||
public String getCustomComponentBundlePath();
|
||||
|
||||
public Set<IComponent> getComponentsForInit();
|
||||
|
||||
public Set<File> getProviderInstallationFolders();
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.model.components;
|
||||
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
|
||||
/**
|
||||
@@ -26,4 +27,11 @@ public interface IComponentsService extends IService {
|
||||
|
||||
public IComponentFileNaming getComponentFileNaming();
|
||||
|
||||
public static IComponentsService get() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsService.class)) {
|
||||
return GlobalServiceRegister.getDefault().getService(IComponentsService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,12 +14,14 @@ package org.talend.core.model.general;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.osgi.framework.Version;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.database.conn.version.DatabaseDriversCache;
|
||||
@@ -29,6 +31,9 @@ import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.utils.json.JSONException;
|
||||
import org.talend.utils.json.JSONObject;
|
||||
import org.talend.utils.json.JSONTokener;
|
||||
|
||||
/**
|
||||
* This bean is use to manage needed moduless (perl) and libraries (java).<br/>
|
||||
@@ -38,6 +43,8 @@ import org.talend.core.utils.TalendQuoteUtils;
|
||||
*/
|
||||
public class ModuleNeeded {
|
||||
|
||||
public static final String ATTR_USED_BY_DYNAMIC_DISTRIBUTION = "dynamicDistribution";
|
||||
|
||||
private String id;
|
||||
|
||||
private String context;
|
||||
@@ -94,6 +101,8 @@ public class ModuleNeeded {
|
||||
*/
|
||||
private boolean useReleaseVersion = false;
|
||||
|
||||
private Map<String, String> attributes;
|
||||
|
||||
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
|
||||
@@ -162,6 +171,10 @@ public class ModuleNeeded {
|
||||
this.required = required;
|
||||
this.installURL = installURL;
|
||||
this.requiredIf = requiredIf;
|
||||
this.attributes = analyseMessage(informationMsg);
|
||||
if (!this.attributes.isEmpty()) {
|
||||
this.informationMsg = "";
|
||||
}
|
||||
String name = moduleName;
|
||||
String uri = mavenUrl;
|
||||
if (moduleName != null) {
|
||||
@@ -184,6 +197,32 @@ public class ModuleNeeded {
|
||||
setMavenUri(uri);
|
||||
}
|
||||
|
||||
private Map<String, String> analyseMessage(String msg) {
|
||||
Map<String, String> attrMap = new HashMap<>();
|
||||
if (StringUtils.isBlank(msg) || !msg.startsWith("{") || !msg.endsWith("}")) {
|
||||
return attrMap;
|
||||
}
|
||||
try {
|
||||
JSONObject jo = new JSONObject(new JSONTokener(msg));
|
||||
Iterator<String> keys = jo.keys();
|
||||
keys.forEachRemaining(key -> {
|
||||
try {
|
||||
Object object = jo.get(key);
|
||||
if (object != null) {
|
||||
attrMap.put(key, object.toString());
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
if (Boolean.getBoolean("talend.studio.moduleNeeded.init.debug")) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return attrMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleNeeded clone() {
|
||||
ModuleNeeded cloned = new ModuleNeeded(context, moduleName, informationMsg, mrRequired, installURL, requiredIf, mavenUri);
|
||||
@@ -212,6 +251,7 @@ public class ModuleNeeded {
|
||||
cloned.requiredIf = requiredIf;
|
||||
cloned.status = status;
|
||||
cloned.useReleaseVersion = useReleaseVersion;
|
||||
cloned.attributes = attributes;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
@@ -671,6 +711,10 @@ public class ModuleNeeded {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean usedByDynamicDistribution() {
|
||||
return Boolean.valueOf(attributes.get(ATTR_USED_BY_DYNAMIC_DISTRIBUTION));
|
||||
}
|
||||
|
||||
public boolean isDynamic() {
|
||||
return this.dynamic;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
@@ -62,7 +63,6 @@ import org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType
|
||||
import org.talend.designer.runprocess.ItemCacheManager;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
/**
|
||||
* DOC bqian class global comment. Detailled comment
|
||||
|
||||
@@ -146,7 +146,7 @@ public class TalendMavenResolver {
|
||||
getMavenResolver();
|
||||
}
|
||||
|
||||
private static MavenResolver getMavenResolver() throws RuntimeException {
|
||||
public static MavenResolver getMavenResolver() throws RuntimeException {
|
||||
if (mavenResolver == null) {
|
||||
final BundleContext context = CoreRuntimePlugin.getInstance().getBundle().getBundleContext();
|
||||
ServiceReference<org.ops4j.pax.url.mvn.MavenResolver> mavenResolverService = context
|
||||
|
||||
@@ -31,6 +31,8 @@ public interface IDynamicDistributionManager {
|
||||
|
||||
public void reloadAllDynamicDistributions(IProgressMonitor monitor) throws Exception;
|
||||
|
||||
public void reset(IProgressMonitor monitor);
|
||||
|
||||
public boolean isLoaded();
|
||||
|
||||
public void load(IProgressMonitor monitor, boolean resetModulesCache) throws Exception;
|
||||
@@ -40,4 +42,7 @@ public interface IDynamicDistributionManager {
|
||||
public boolean isUsersDynamicDistribution(String dynamicDistributionId);
|
||||
|
||||
public String getDynamicDistributionCacheVersion();
|
||||
|
||||
public String getPluginExtensionCacheVersion();
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
|
||||
/**
|
||||
* created by ycbai on 2016年3月24日 Detailled comment
|
||||
@@ -28,6 +29,20 @@ import org.talend.core.model.process.INode;
|
||||
*/
|
||||
public interface IGenericService extends IService {
|
||||
|
||||
/**
|
||||
* Get all the names of generic type.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> getGenericTypeNames();
|
||||
|
||||
/**
|
||||
* Create repository nodes by component service.
|
||||
*
|
||||
* @param curParentNode
|
||||
*/
|
||||
public List<RepositoryNode> createNodesFromComponentService(RepositoryNode curParentNode);
|
||||
|
||||
/**
|
||||
* Call method <code>callBeforeActivate()</code> of <code>parameter</code>.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.runtime.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.components.api.service.ComponentService;
|
||||
import org.talend.components.api.wizard.ComponentWizard;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.repository.model.IRepositoryNode.ENodeType;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
|
||||
/**
|
||||
* created by ycbai on 2015年9月21日 Detailled comment
|
||||
*
|
||||
*/
|
||||
public interface IGenericWizardInternalService extends IService {
|
||||
|
||||
public ERepositoryObjectType createRepositoryType(String type, String label, String alias, String folder, int ordinal);
|
||||
|
||||
public RepositoryNode createRepositoryNode(RepositoryNode curParentNode, String label, ERepositoryObjectType type,
|
||||
ENodeType nodeType);
|
||||
|
||||
public ComponentService getComponentService();
|
||||
|
||||
public ComponentWizard getComponentWizard(String name, String location);
|
||||
|
||||
public List<ComponentWizard> getComponentWizardsForProperties(ComponentProperties properties, String location);
|
||||
|
||||
public ComponentWizard getTopLevelComponentWizard(ComponentProperties properties, String location);
|
||||
|
||||
public static IGenericWizardInternalService getService() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardInternalService.class)) {
|
||||
return GlobalServiceRegister.getDefault().getService(IGenericWizardInternalService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,20 +39,6 @@ import org.talend.repository.model.RepositoryNode;
|
||||
*/
|
||||
public interface IGenericWizardService extends IService {
|
||||
|
||||
/**
|
||||
* Create repository nodes by component service.
|
||||
*
|
||||
* @param curParentNode
|
||||
*/
|
||||
public List<RepositoryNode> createNodesFromComponentService(RepositoryNode curParentNode);
|
||||
|
||||
/**
|
||||
* Get all the names of generic type.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> getGenericTypeNames();
|
||||
|
||||
/**
|
||||
*
|
||||
* Estimate whether <code>repObjType</code> is a generic type or not.
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.runtime.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.jdt.launching.IVMInstall;
|
||||
import org.eclipse.jdt.launching.IVMInstall2;
|
||||
import org.eclipse.jdt.launching.JavaRuntime;
|
||||
import org.talend.commons.utils.generation.JavaUtils;
|
||||
|
||||
/**
|
||||
* created by nrousseau on Jun 13, 2015 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class JavaHomeUtil {
|
||||
|
||||
/**
|
||||
* Initialize Java Home to the preferences if needed only.<br>
|
||||
*
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static void initializeJavaHome() throws CoreException {
|
||||
IEclipsePreferences pref = InstanceScope.INSTANCE.getNode(JavaRuntime.ID_PLUGIN); //$NON-NLS-1$
|
||||
String defaultVM = pref.get(JavaRuntime.PREF_VM_XML, ""); //$NON-NLS-1$//$NON-NLS-2$
|
||||
boolean needSetupJVM = false;
|
||||
if (!"".equals(defaultVM)) { //$NON-NLS-1$
|
||||
if (isSetJdkHomeVariable() && !getJDKHomeVariable().equals(getCurrentJavaHomeString())) {
|
||||
needSetupJVM = true;
|
||||
}
|
||||
} else {
|
||||
needSetupJVM = true;
|
||||
}
|
||||
if (needSetupJVM) {
|
||||
IVMInstall currentVM = JavaRuntime.getDefaultVMInstall();
|
||||
if (isSetJdkHomeVariable()) {
|
||||
if (currentVM != null) {
|
||||
File installLocation = new File(getJDKHomeVariable());
|
||||
currentVM.setInstallLocation(installLocation);
|
||||
currentVM.setName(installLocation.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Only for TUJ to setup JDK version
|
||||
* Should invoke after initializeJavaHome()
|
||||
*/
|
||||
public static String getSpecifiedJavaVersion() {
|
||||
if (isSetJdkHomeVariable()) {
|
||||
IVMInstall currentVM = JavaRuntime.getDefaultVMInstall();
|
||||
if (currentVM instanceof IVMInstall2) {
|
||||
return JavaUtils.getCompilerCompliance((IVMInstall2) currentVM, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isSetJdkHomeVariable() {
|
||||
String jdkHomeValue = getJDKHomeVariable();
|
||||
return jdkHomeValue != null && !"".equals(jdkHomeValue); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static String getJDKHomeVariable() {
|
||||
String jdkHome = System.getProperty("job.compilation.jvm"); //$NON-NLS-1$
|
||||
if (jdkHome == null || "".equals(jdkHome)) { //$NON-NLS-1$
|
||||
jdkHome = System.getProperty("jdk.home"); //$NON-NLS-1$
|
||||
}
|
||||
if (StringUtils.isNoneEmpty(jdkHome)) {
|
||||
File jvmFile = new File(jdkHome);
|
||||
if (jvmFile.exists()) {
|
||||
return getJDKPath(jvmFile);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getJDKPath(File file) {
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
if ("bin".equals(file.getName())) {//$NON-NLS-1$
|
||||
return file.getParent();
|
||||
} else {
|
||||
return getJDKPath(file.getParentFile());
|
||||
}
|
||||
}
|
||||
|
||||
public static File getCurrentJavaHomeFile() {
|
||||
IVMInstall currentVM = JavaRuntime.getDefaultVMInstall();
|
||||
if (currentVM == null) {
|
||||
return null;
|
||||
}
|
||||
return currentVM.getInstallLocation();
|
||||
}
|
||||
|
||||
public static String getCurrentJavaHomeString() {
|
||||
IVMInstall currentVM = JavaRuntime.getDefaultVMInstall();
|
||||
if (currentVM == null) {
|
||||
return null;
|
||||
}
|
||||
return currentVM.getInstallLocation().getAbsolutePath();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
@@ -22,6 +23,7 @@ import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IProxyRepositoryService;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
|
||||
public class CodesJarResourceCache {
|
||||
|
||||
@@ -29,12 +31,14 @@ public class CodesJarResourceCache {
|
||||
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
private static boolean isListenerAdded;
|
||||
private static AtomicBoolean isInitialized = new AtomicBoolean(false);
|
||||
|
||||
private static AtomicBoolean isInitializing = new AtomicBoolean(true);
|
||||
|
||||
private static PropertyChangeListener listener;
|
||||
|
||||
public static void initCodesJarCache() {
|
||||
synchronized (LOCK) {
|
||||
if (isInitialized.compareAndSet(false, true)) {
|
||||
CACHE.clear();
|
||||
List<Project> allProjects = new ArrayList<>();
|
||||
allProjects.addAll(ProjectManager.getInstance().getAllReferencedProjects(true));
|
||||
@@ -49,40 +53,43 @@ public class CodesJarResourceCache {
|
||||
}
|
||||
}
|
||||
}
|
||||
addCodesJarChangeListener();
|
||||
if (listener == null) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService service = GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
|
||||
listener = service.addCodesJarChangeListener();
|
||||
}
|
||||
}
|
||||
isInitializing.set(false);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
throw new RuntimeException("Failed to init resource cache for custom jars", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<CodesJarInfo> getAllCodesJars() {
|
||||
synchronized (LOCK) {
|
||||
return new LinkedHashSet<>(CACHE);
|
||||
}
|
||||
waitForInit();
|
||||
return new LinkedHashSet<>(CACHE);
|
||||
}
|
||||
|
||||
public static CodesJarInfo getCodesJarById(String id) {
|
||||
synchronized (LOCK) {
|
||||
Optional<CodesJarInfo> optional = CACHE.stream().filter(info -> info.getId().equals(id)).findFirst();
|
||||
if (optional.isPresent()) {
|
||||
return optional.get();
|
||||
}
|
||||
ExceptionHandler.process(new Exception("Codes jar id [" + id + "] is not found!")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return null;
|
||||
waitForInit();
|
||||
Optional<CodesJarInfo> optional = CACHE.stream().filter(info -> info.getId().equals(id)).findFirst();
|
||||
if (optional.isPresent()) {
|
||||
return optional.get();
|
||||
}
|
||||
ExceptionHandler.process(new Exception("Codes jar id [" + id + "] is not found!")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CodesJarInfo getCodesJarByLabel(ERepositoryObjectType type, String projectTechName, String label) {
|
||||
synchronized (LOCK) {
|
||||
Optional<CodesJarInfo> optional = CACHE.stream().filter(info -> info.getType() == type
|
||||
&& info.getLabel().equals(label) && info.getProjectTechName().equals(projectTechName)).findFirst();
|
||||
if (optional.isPresent()) {
|
||||
return optional.get();
|
||||
}
|
||||
ExceptionHandler.process(new Exception("Codes jar [" + label + "] is not found!")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return null;
|
||||
waitForInit();
|
||||
Optional<CodesJarInfo> optional = CACHE.stream().filter(info -> info.getType() == type && info.getLabel().equals(label)
|
||||
&& info.getProjectTechName().equals(projectTechName)).findFirst();
|
||||
if (optional.isPresent()) {
|
||||
return optional.get();
|
||||
}
|
||||
ExceptionHandler.process(new Exception("Codes jar [" + label + "] is not found!")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CodesJarInfo getCodesJarByInnerCode(RoutineItem routineItem) throws PersistenceException {
|
||||
@@ -99,6 +106,7 @@ public class CodesJarResourceCache {
|
||||
}
|
||||
|
||||
public static void addToCache(Property newProperty) {
|
||||
waitForInit();
|
||||
synchronized (LOCK) {
|
||||
Iterator<CodesJarInfo> iterator = CACHE.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -113,6 +121,7 @@ public class CodesJarResourceCache {
|
||||
}
|
||||
|
||||
public static void updateCache(String oldId, String oldLabel, String oldVersion, Property newProperty) {
|
||||
waitForInit();
|
||||
synchronized (LOCK) {
|
||||
Iterator<CodesJarInfo> iterator = CACHE.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -127,6 +136,7 @@ public class CodesJarResourceCache {
|
||||
}
|
||||
|
||||
public static void removeCache(Property property) {
|
||||
waitForInit();
|
||||
synchronized (LOCK) {
|
||||
Iterator<CodesJarInfo> iterator = CACHE.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -139,18 +149,31 @@ public class CodesJarResourceCache {
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCodesJarChangeListener() {
|
||||
if (!isListenerAdded) {
|
||||
synchronized (LOCK) {
|
||||
if (!isListenerAdded) {
|
||||
if (listener == null) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService service = GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
|
||||
listener = service.addCodesJarChangeListener();
|
||||
isListenerAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void reset() {
|
||||
if (isInitialized.compareAndSet(true, false)) {
|
||||
if (listener != null) {
|
||||
IRepositoryService.get().getProxyRepositoryFactory().removePropertyChangeListener(listener);
|
||||
listener = null;
|
||||
}
|
||||
isInitializing.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void waitForInit() {
|
||||
initCodesJarCache();
|
||||
int spent = 0;
|
||||
int time = 500;
|
||||
int timeout = 1000 * 60 * 10;
|
||||
while (isInitializing.get()) {
|
||||
try {
|
||||
Thread.sleep(time);
|
||||
spent += time;
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (spent >= timeout) {
|
||||
// may be track in dead lock, throw exception to try to break dead lock
|
||||
throw new RuntimeException("Waiting for custom jar cache initialization timeout!"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,9 @@ public abstract class AbstractLoginTask implements ILoginTask {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBackground() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.PluginChecker;
|
||||
|
||||
/**
|
||||
* created by wchen on 2015-5-15 Detailled comment Define a login taks that will be execute when login project
|
||||
@@ -28,9 +31,26 @@ public interface ILoginTask {
|
||||
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException;
|
||||
|
||||
default void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
if (CommonsPlugin.isHeadless() || CommonsPlugin.isJUnitTest() || PluginChecker.isSWTBotLoaded()
|
||||
|| CommonsPlugin.isTUJTest() || !isBackground()) {
|
||||
run(monitor);
|
||||
} else {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
run(monitor);
|
||||
} catch (InvocationTargetException | InterruptedException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}, getClass().getCanonicalName()).start();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Which indicates the task will be executed for each logon of a project, by default return false(execute only once
|
||||
* at the time of logon studio).
|
||||
*/
|
||||
boolean isRequiredAlways();
|
||||
|
||||
boolean isBackground();
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.data.container.RootContainer;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.properties.Property;
|
||||
@@ -159,7 +158,7 @@ public abstract class AbsMigrationCheckHandler implements IMigrationCheckHandler
|
||||
return hasCompilationError;
|
||||
}
|
||||
|
||||
protected void checkModules(Set<String> neededLibraries, Set<ModuleNeeded> allModulesWithStatus, MigrateItemInfo itemInfo) {
|
||||
protected void checkModules(Set<String> neededLibraries, MigrateItemInfo itemInfo) {
|
||||
// check libraries status
|
||||
if (neededLibraries == null || neededLibraries.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
@@ -149,4 +150,11 @@ public interface IRepositoryService extends IService {
|
||||
|
||||
List<ModuleNeeded> getLog4j2Modules();
|
||||
|
||||
public static IRepositoryService get() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
return GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -103,6 +103,8 @@ public class RepositoryConstants {
|
||||
public static final String REPOSITORY_CLOUD_APAC_ID = "cloud_apac"; //$NON-NLS-1$
|
||||
|
||||
public static final String REPOSITORY_CLOUD_US_WEST_ID = "cloud_us_west"; //$NON-NLS-1$
|
||||
|
||||
public static final String REPOSITORY_CLOUD_AUS_ID = "cloud_aus"; //$NON-NLS-1$
|
||||
|
||||
public static final String REPOSITORY_CLOUD_CUSTOM_ID = "cloud_custom"; //$NON-NLS-1$
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ Require-Bundle: org.apache.commons.lang,
|
||||
org.apache.httpcomponents.httpcore,
|
||||
org.apache.httpcomponents.httpclient,
|
||||
org.slf4j.api,
|
||||
org.apache.ant
|
||||
org.apache.ant,
|
||||
org.eclipse.m2e.maven.runtime
|
||||
Import-Package: org.eclipse.jdt.internal.ui.workingsets
|
||||
Export-Package: org.talend.core.ui,
|
||||
org.talend.core.ui.actions,
|
||||
|
||||
@@ -9,21 +9,7 @@
|
||||
</parent>
|
||||
<artifactId>org.talend.core.ui</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>5.2.5</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -32,17 +18,33 @@
|
||||
<version>3.0.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includeScope>runtime</includeScope>
|
||||
<outputDirectory>${project.basedir}/lib</outputDirectory>
|
||||
<stripVersion>true</stripVersion>
|
||||
</configuration>
|
||||
</execution>
|
||||
<id>copy</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.basedir}/lib</outputDirectory>
|
||||
<stripVersion>true</stripVersion>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>5.2.5</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>5.6.0</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>5.6.0</version>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -15,13 +15,13 @@ package org.talend.core.ui.advanced.composite;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.text.StringMatcher;
|
||||
import org.eclipse.jface.viewers.AbstractTreeViewer;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.StructuredViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.ui.internal.misc.StringMatcher;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
|
||||
@@ -644,11 +644,6 @@ public class ContextTreeTable {
|
||||
super(treeList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatDataForDepth(int depth, ContextTreeNode object) {
|
||||
return object.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ContextExpansionModel implements TreeList.ExpansionModel<ContextTreeNode> {
|
||||
|
||||
@@ -14,10 +14,10 @@ package org.talend.core.ui.context;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageRegistry;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.jface.util.Assert;
|
||||
import org.eclipse.jface.viewers.CellEditor;
|
||||
import org.eclipse.jface.viewers.DialogCellEditor;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.talend.core.ui.i18n.Messages;
|
||||
* created by ldong on Aug 14, 2014 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class ContextMenuItemProviders extends MenuItemProviders {
|
||||
public class ContextMenuItemProviders {
|
||||
|
||||
// the item of change the context parameter's mode such as from repositroy to build-in
|
||||
public static IMenuItemProvider changeModeMenuItemProvider(final IDataProvider dataProvider,
|
||||
@@ -122,7 +122,7 @@ public class ContextMenuItemProviders extends MenuItemProviders {
|
||||
}
|
||||
|
||||
private static ContextTreeNode getTreeNodeByRightClickPostion(final IDataProvider dataProvider, SelectionEvent e) {
|
||||
NatEventData natEventData = getNatEventData(e);
|
||||
NatEventData natEventData = MenuItemProviders.getNatEventData(e);
|
||||
NatTable nt = natEventData.getNatTable();
|
||||
int rowPosition = natEventData.getRowPosition();
|
||||
int rowIndex = nt.getRowIndexByPosition(rowPosition);
|
||||
|
||||
@@ -14,10 +14,10 @@ package org.talend.core.ui.context.nattableTree;
|
||||
|
||||
import org.eclipse.nebula.widgets.nattable.NatTable;
|
||||
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
|
||||
import org.eclipse.nebula.widgets.nattable.edit.action.CellEditDragMode;
|
||||
import org.eclipse.nebula.widgets.nattable.edit.action.MouseEditAction;
|
||||
import org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings;
|
||||
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
|
||||
import org.eclipse.nebula.widgets.nattable.selection.action.CellSelectionDragMode;
|
||||
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
|
||||
import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
@@ -53,6 +53,6 @@ public class ContextSelectBindings extends DefaultEditBindings {
|
||||
|
||||
};
|
||||
pUiBindingRegistry.registerSingleClickBinding(mouseEventMatcher, new MouseEditAction());
|
||||
pUiBindingRegistry.registerFirstMouseDragMode(mouseEventMatcher, new CellEditDragMode());
|
||||
pUiBindingRegistry.registerFirstMouseDragMode(mouseEventMatcher, new CellSelectionDragMode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable;
|
||||
import org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultTableLabelProvider;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.CasePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.QuotePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.ResetDBTypesPushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton;
|
||||
import org.talend.commons.ui.swt.tableviewer.TableViewerCreator;
|
||||
@@ -88,6 +90,14 @@ public class CustomTableManager {
|
||||
if (resetDBTypesButton != null) {
|
||||
resetDBTypesButton.getButton().setEnabled(false);
|
||||
}
|
||||
CasePushButton caseButton = tableEditorView.getExtendedToolbar().getCaseButton();
|
||||
if (caseButton != null) {
|
||||
caseButton.getButton().setEnabled(false);
|
||||
}
|
||||
QuotePushButton quoteButton = tableEditorView.getExtendedToolbar().getQuoteButton();
|
||||
if (quoteButton != null) {
|
||||
quoteButton.getButton().setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
tableEditorView.getToolBar().getAddButton().getButton().addSelectionListener(new SelectionListener() {
|
||||
|
||||
@@ -170,6 +180,14 @@ public class CustomTableManager {
|
||||
if (resetDBTypesButton != null) {
|
||||
resetDBTypesButton.getButton().setEnabled(false);
|
||||
}
|
||||
CasePushButton caseButton = tableEditorView.getExtendedToolbar().getCaseButton();
|
||||
if (caseButton != null) {
|
||||
caseButton.getButton().setEnabled(false);
|
||||
}
|
||||
QuotePushButton quoteButton = tableEditorView.getExtendedToolbar().getQuoteButton();
|
||||
if (quoteButton != null) {
|
||||
quoteButton.getButton().setEnabled(false);
|
||||
}
|
||||
}
|
||||
if (linkedTable != null) {
|
||||
if (linkedTable.isReadOnly() && linkedTableEditorView != null) {
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.talend.commons.ui.command.CommandStackForComposite;
|
||||
import org.talend.commons.ui.runtime.image.EImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.swt.advanced.composite.ThreeCompositesSashForm;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.ExtendedToolbarView;
|
||||
import org.talend.commons.ui.swt.extended.table.ExtendedTableModel;
|
||||
import org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener;
|
||||
import org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent;
|
||||
@@ -67,6 +68,7 @@ import org.talend.core.model.utils.NodeUtil;
|
||||
import org.talend.core.ui.CoreUIPlugin;
|
||||
import org.talend.core.ui.i18n.Messages;
|
||||
import org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView;
|
||||
import org.talend.core.ui.metadata.editor.MetadataQuoteToolbarEditorView;
|
||||
import org.talend.core.ui.metadata.editor.MetadataTableEditor;
|
||||
import org.talend.core.ui.metadata.editor.MetadataTableEditorView;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
@@ -376,8 +378,19 @@ public class MetadataDialog extends Dialog {
|
||||
} else {
|
||||
metadataTableEditor = new MetadataTableEditor(outputMetaTable, titleOutput);
|
||||
}
|
||||
outputMetaView = new DialogMetadataTableEditorView(composite, SWT.NONE, metadataTableEditor, outputReadOnly, true,
|
||||
true, false);
|
||||
//enable dbcolumn manipulate feature only on Database output component
|
||||
String nodeFamily = "", rootFamily = "";
|
||||
if ( outputNode != null && outputNode.getComponent() != null ) {
|
||||
nodeFamily = outputNode.getComponent().getOriginalFamilyName();
|
||||
rootFamily = nodeFamily != null ? nodeFamily.split("/")[0] : "";
|
||||
}
|
||||
if (rootFamily.equals("Databases")) {
|
||||
outputMetaView = new DialogMetadataDBOutputTableEditorView(composite, SWT.NONE, metadataTableEditor, outputReadOnly, true,
|
||||
true, false);
|
||||
} else {
|
||||
outputMetaView = new DialogMetadataTableEditorView(composite, SWT.NONE, metadataTableEditor, outputReadOnly, true,
|
||||
true, false);
|
||||
}
|
||||
outputMetaView.setMetadataTalendTypeFilter(NodeUtil.createMetadataTalendTypeFilter(outputNode));
|
||||
outputMetaView.setIsRepository(isRepository(outputNode, outputMetaTable));
|
||||
initializeMetadataTableView(outputMetaView, outputNode, outputMetaTable);
|
||||
@@ -544,8 +557,21 @@ public class MetadataDialog extends Dialog {
|
||||
} else {
|
||||
metadataTableEditorForOutput = new MetadataTableEditor(outputMetaTable, titleOutput + " (Output)");
|
||||
}
|
||||
outputMetaView = new DialogMetadataTableEditorView(compositesSachForm.getRightComposite(), SWT.NONE,
|
||||
metadataTableEditorForOutput, outputReadOnly, true, true, false);
|
||||
//Enable dbcolumn manipulate feature only on Database output component
|
||||
String nodeFamily = "", rootFamily = "";
|
||||
if ( outputNode != null && outputNode.getComponent() != null ) {
|
||||
nodeFamily = outputNode.getComponent().getOriginalFamilyName();
|
||||
rootFamily = nodeFamily != null ? nodeFamily.split("/")[0] : "";
|
||||
}
|
||||
if (rootFamily.equals("Databases")) {
|
||||
outputMetaView = new DialogMetadataDBOutputTableEditorView(compositesSachForm.getRightComposite(), SWT.NONE,
|
||||
metadataTableEditorForOutput, outputReadOnly, true, true, false);
|
||||
} else {
|
||||
outputMetaView = new DialogMetadataTableEditorView(compositesSachForm.getRightComposite(), SWT.NONE,
|
||||
metadataTableEditorForOutput, outputReadOnly, true, true, false);
|
||||
}
|
||||
|
||||
|
||||
outputMetaView.setMetadataTalendTypeFilter(NodeUtil.createMetadataTalendTypeFilter(outputNode));
|
||||
outputMetaView.setIsRepository(isRepository(outputNode, outputMetaTable));
|
||||
initializeMetadataTableView(outputMetaView, outputNode, outputMetaTable);
|
||||
@@ -799,7 +825,22 @@ public class MetadataDialog extends Dialog {
|
||||
newTableViewerCreator.setLazyLoad(TableViewerCreator.getRecommandLazyLoad());
|
||||
}
|
||||
}
|
||||
|
||||
class DialogMetadataDBOutputTableEditorView extends MetadataTableEditorView {
|
||||
|
||||
public DialogMetadataDBOutputTableEditorView(Composite parentComposite, int mainCompositeStyle,
|
||||
ExtendedTableModel<IMetadataColumn> extendedTableModel, boolean readOnly, boolean toolbarVisible,
|
||||
boolean labelVisible, boolean initGraphicsComponents) {
|
||||
super(parentComposite, mainCompositeStyle, extendedTableModel, readOnly, toolbarVisible, labelVisible,
|
||||
initGraphicsComponents);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExtendedToolbarView initToolBar() {
|
||||
return new MetadataQuoteToolbarEditorView(getMainComposite(), SWT.NONE, this.getExtendedTableViewer(), this.getCurrentDbms());
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSingleAndStruct(boolean isSingle) {
|
||||
isSingleAndStruct = isSingle;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.ui.metadata.editor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.QuotePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.QuotePushButtonForExtendedTable;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.CasePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.CasePushButtonForExtendedTable;
|
||||
import org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer;
|
||||
import org.talend.commons.ui.swt.extended.table.ExtendedTableModel;
|
||||
import org.talend.core.ui.metadata.extended.command.MetadataCaseCommand;
|
||||
import org.talend.core.ui.metadata.extended.command.MetadataQuoteCommand;
|
||||
|
||||
|
||||
public class MetadataQuoteToolbarEditorView extends MetadataToolbarEditorView {
|
||||
|
||||
|
||||
public MetadataQuoteToolbarEditorView(Composite parent, int style, AbstractExtendedTableViewer extendedTableViewer) {
|
||||
super(parent, style, extendedTableViewer);
|
||||
}
|
||||
|
||||
public MetadataQuoteToolbarEditorView(Composite parent, int style, AbstractExtendedTableViewer extendedTableViewer, String dbmsId) {
|
||||
super(parent, style, extendedTableViewer, dbmsId);
|
||||
this.getQuoteButton().setDbmsId(dbmsId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CasePushButton createCasePushButton() {
|
||||
return new CasePushButtonForExtendedTable(toolbar, extendedTableViewer) {
|
||||
|
||||
@Override
|
||||
protected Command getCommandToExecute(ExtendedTableModel extendedTable, List beansToConvertCase, int[] selectionIndices, boolean isUpperCase) {
|
||||
return new MetadataCaseCommand(extendedTable, beansToConvertCase, selectionIndices, isUpperCase);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QuotePushButton createQuotePushButton() {
|
||||
return new QuotePushButtonForExtendedTable(toolbar, extendedTableViewer) {
|
||||
|
||||
@Override
|
||||
protected Command getCommandToExecute(ExtendedTableModel extendedTable, List beansToQuote, int[] selectionIndices, String quote, boolean isAddingQuote) {
|
||||
return new MetadataQuoteCommand(extendedTable, beansToQuote, selectionIndices, quote, isAddingQuote);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.ui.metadata.extended.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTableCaseCommand;
|
||||
import org.talend.commons.ui.swt.extended.table.ExtendedTableModel;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataColumn;
|
||||
import org.talend.core.model.metadata.builder.connection.impl.ConnectionFactoryImpl;
|
||||
import org.talend.core.ui.metadata.editor.MetadataTableEditor;
|
||||
|
||||
public class MetadataCaseCommand extends ExtendedTableCaseCommand {
|
||||
|
||||
|
||||
/**
|
||||
* DOC MetadataCaseCommand constructor comment.
|
||||
*
|
||||
* @param extendedTableModel
|
||||
* @param beansToUppercase
|
||||
* @param selectionIndices
|
||||
* @param isUpperCase
|
||||
*/
|
||||
public MetadataCaseCommand(ExtendedTableModel extendedTable, List beansToUppercase, int[] selectionIndices, boolean isUpperCase) {
|
||||
super(extendedTable, beansToUppercase, selectionIndices, isUpperCase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertCase(ExtendedTableModel extendedTable, List copiedObjectsList, int[] selectionIndices, boolean isUpperCase) {
|
||||
int index = 0;
|
||||
for (Object current : copiedObjectsList) {
|
||||
//get refreshed element
|
||||
current = extendedTable.getTableViewer().getElementAt(selectionIndices[index]);
|
||||
if (current instanceof IMetadataColumn) {
|
||||
IMetadataColumn copy = ((IMetadataColumn) current).clone();
|
||||
copy.setUsefulColumn(true);
|
||||
if (copy.getOriginalDbColumnName() != null && !StringUtils.isEmpty(copy.getOriginalDbColumnName())) {
|
||||
copy.setOriginalDbColumnName(isUpperCase ? copy.getOriginalDbColumnName().toUpperCase() : copy.getOriginalDbColumnName().toLowerCase());
|
||||
}
|
||||
extendedTable.replace(copy, selectionIndices[index]);
|
||||
}
|
||||
// Add a new statement to fix the MetadataColumn type.
|
||||
else if (current instanceof MetadataColumn) {
|
||||
MetadataTableEditor tableEditor = (MetadataTableEditor) extendedTable;
|
||||
MetadataColumn metadataColumn = (MetadataColumn) current;
|
||||
MetadataColumn newColumnCopy = new ConnectionFactoryImpl().copy(metadataColumn,
|
||||
isUpperCase ? StringUtils.upperCase(metadataColumn.getName()) : StringUtils.lowerCase(metadataColumn.getName()));
|
||||
IMetadataColumn copy = (ConvertionHelper.convertToIMetaDataColumn(newColumnCopy)).clone();
|
||||
extendedTable.replace(copy, selectionIndices[index]);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
extendedTable.getTableViewer().getTable().select(selectionIndices);
|
||||
extendedTable.getTableViewer().getTable().notifyListeners(SWT.Selection, new Event());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.ui.metadata.extended.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTableQuoteCommand;
|
||||
import org.talend.commons.ui.swt.extended.table.ExtendedTableModel;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataColumn;
|
||||
import org.talend.core.model.metadata.builder.connection.impl.ConnectionFactoryImpl;
|
||||
import org.talend.core.ui.metadata.editor.MetadataTableEditor;
|
||||
|
||||
public class MetadataQuoteCommand extends ExtendedTableQuoteCommand {
|
||||
|
||||
|
||||
/**
|
||||
* DOC MetadataQuoteCommand constructor comment.
|
||||
*
|
||||
* @param extendedTableModel
|
||||
* @param beansToQuote
|
||||
* @param selectionIndices
|
||||
*/
|
||||
public MetadataQuoteCommand(ExtendedTableModel extendedTable, List beansToQuote, int[] selectionIndices, String quote, boolean isAddingQuote) {
|
||||
super(extendedTable, beansToQuote, selectionIndices, quote, isAddingQuote);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toQuote(ExtendedTableModel extendedTable, List copiedObjectsList, int[] selectionIndices, String quote, boolean isAddingQuote) {
|
||||
int index = 0;
|
||||
for (Object current : copiedObjectsList) {
|
||||
//get refreshed element
|
||||
current = extendedTable.getTableViewer().getElementAt(selectionIndices[index]);
|
||||
if (current instanceof IMetadataColumn) {
|
||||
IMetadataColumn copy = ((IMetadataColumn) current).clone();
|
||||
copy.setUsefulColumn(true);
|
||||
String oldDbColumnName = copy.getOriginalDbColumnName();
|
||||
if (oldDbColumnName != null) {
|
||||
String newDbColumnName = oldDbColumnName;
|
||||
if (isAddingQuote) {
|
||||
newDbColumnName = quote + newDbColumnName + quote;
|
||||
} else {
|
||||
newDbColumnName = StringUtils.removeStart(oldDbColumnName, quote);
|
||||
newDbColumnName = StringUtils.removeEnd(newDbColumnName, quote);
|
||||
}
|
||||
copy.setOriginalDbColumnName(newDbColumnName);
|
||||
extendedTable.replace(copy, selectionIndices[index]);
|
||||
}
|
||||
}
|
||||
// Add a new statement to fix the MetadataColumn type.
|
||||
else if (current instanceof MetadataColumn) {
|
||||
MetadataTableEditor tableEditor = (MetadataTableEditor) extendedTable;
|
||||
MetadataColumn metadataColumn = (MetadataColumn) current;
|
||||
String oldName = metadataColumn.getName();
|
||||
if (oldName != null) {
|
||||
String newName = oldName;
|
||||
if (isAddingQuote) {
|
||||
newName = quote + oldName + quote;
|
||||
} else {
|
||||
newName = StringUtils.removeStart(oldName, quote);
|
||||
newName = StringUtils.removeEnd(newName, quote);
|
||||
}
|
||||
MetadataColumn newColumnCopy = new ConnectionFactoryImpl().copy(metadataColumn, newName);
|
||||
IMetadataColumn copy = (ConvertionHelper.convertToIMetaDataColumn(newColumnCopy)).clone();
|
||||
extendedTable.replace(copy, selectionIndices[index]);
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
extendedTable.getTableViewer().getTable().select(selectionIndices);
|
||||
extendedTable.getTableViewer().getTable().notifyListeners(SWT.Selection, new Event());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.aether.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||
import org.eclipse.aether.RepositorySystem;
|
||||
import org.eclipse.aether.RepositorySystemSession;
|
||||
import org.eclipse.aether.artifact.Artifact;
|
||||
import org.eclipse.aether.artifact.DefaultArtifact;
|
||||
import org.eclipse.aether.repository.Authentication;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
import org.eclipse.aether.repository.RepositoryPolicy;
|
||||
import org.eclipse.aether.resolution.ArtifactRequest;
|
||||
import org.eclipse.aether.resolution.ArtifactResult;
|
||||
import org.eclipse.aether.transfer.TransferCancelledException;
|
||||
import org.eclipse.aether.transfer.TransferEvent;
|
||||
import org.eclipse.aether.transfer.TransferListener;
|
||||
import org.eclipse.aether.util.repository.AuthenticationBuilder;
|
||||
import org.talend.core.download.DownloadListener;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.designer.maven.aether.util.exception.ResolveFailedException;
|
||||
|
||||
public class AetherArtifactDownloadProvider implements TransferListener {
|
||||
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
private RepositorySystemSession repositorySystemSession;
|
||||
|
||||
private static Exception initFailedException = null;
|
||||
|
||||
private List<DownloadListener> downloadListeners = new ArrayList<DownloadListener>();
|
||||
|
||||
public AetherArtifactDownloadProvider() throws Exception {
|
||||
this.repositorySystem = MavenLibraryResolverProvider.newRepositorySystemForResolver();
|
||||
this.repositorySystemSession = MavenLibraryResolverProvider.newSession(repositorySystem,
|
||||
MavenLibraryResolverProvider.getLocalMVNRepository());
|
||||
if (this.repositorySystemSession instanceof DefaultRepositorySystemSession) {
|
||||
((DefaultRepositorySystemSession) this.repositorySystemSession).setChecksumPolicy(getChecksumPolicy());
|
||||
((DefaultRepositorySystemSession) this.repositorySystemSession).setUpdatePolicy(getUpdatePolicy());
|
||||
((DefaultRepositorySystemSession) this.repositorySystemSession).setTransferListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public File resolveArtifact(MavenArtifact aritfact, ArtifactRepositoryBean nexusServer) throws Exception {
|
||||
if (repositorySystem == null || repositorySystemSession == null) {
|
||||
throw initFailedException;
|
||||
}
|
||||
ArtifactRequest artifactRequest = new ArtifactRequest();
|
||||
RemoteRepository defaultRemoteRepository = null;
|
||||
if (nexusServer.getUserName() == null && nexusServer.getPassword() == null) {
|
||||
defaultRemoteRepository = new RemoteRepository.Builder("talend", "default", nexusServer.getRepositoryURL()).build(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} else {
|
||||
Authentication authentication = new AuthenticationBuilder().addUsername(nexusServer.getUserName())
|
||||
.addPassword(nexusServer.getPassword()).build();
|
||||
defaultRemoteRepository = new RemoteRepository.Builder("talend", "default", nexusServer.getRepositoryURL()) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
.setAuthentication(authentication).build();
|
||||
}
|
||||
defaultRemoteRepository = new RemoteRepository.Builder(defaultRemoteRepository)
|
||||
.setProxy(new TalendAetherProxySelector().getProxy(defaultRemoteRepository)).build();
|
||||
artifactRequest.addRepository(defaultRemoteRepository);
|
||||
|
||||
Artifact artifact = new DefaultArtifact(aritfact.getGroupId(), aritfact.getArtifactId(), aritfact.getClassifier(),
|
||||
aritfact.getType(), aritfact.getVersion());
|
||||
artifactRequest.setArtifact(artifact);
|
||||
ArtifactResult artifactResult = repositorySystem.resolveArtifact(repositorySystemSession, artifactRequest);
|
||||
if (artifactResult.isResolved()) {
|
||||
return artifactResult.getArtifact().getFile();
|
||||
} else {
|
||||
throw new ResolveFailedException(artifactResult.getExceptions());
|
||||
}
|
||||
}
|
||||
|
||||
public static String getChecksumPolicy() {
|
||||
return RepositoryPolicy.CHECKSUM_POLICY_FAIL;
|
||||
}
|
||||
|
||||
public static String getUpdatePolicy() {
|
||||
return RepositoryPolicy.UPDATE_POLICY_ALWAYS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferInitiated(TransferEvent event) throws TransferCancelledException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferStarted(TransferEvent event) throws TransferCancelledException {
|
||||
if (event != null) {
|
||||
for (DownloadListener listener : downloadListeners) {
|
||||
listener.downloadStart(new Long(event.getResource().getContentLength()).intValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferProgressed(TransferEvent event) throws TransferCancelledException {
|
||||
if (event != null) {
|
||||
for (DownloadListener listener : downloadListeners) {
|
||||
listener.downloadProgress(null, new Long(event.getTransferredBytes()).intValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferCorrupted(TransferEvent event) throws TransferCancelledException {
|
||||
if (event != null) {
|
||||
deleteTransferedData(event);
|
||||
for (DownloadListener listener : downloadListeners) {
|
||||
listener.downloadFailed(event.getException());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferSucceeded(TransferEvent event) {
|
||||
if (event != null) {
|
||||
for (DownloadListener listener : downloadListeners) {
|
||||
listener.downloadComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferFailed(TransferEvent event) {
|
||||
if (event != null) {
|
||||
deleteTransferedData(event);
|
||||
for (DownloadListener listener : downloadListeners) {
|
||||
listener.downloadFailed(event.getException());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteTransferedData(TransferEvent event) {
|
||||
if (event != null && event.getResource() != null && event.getResource().getFile() != null
|
||||
&& event.getResource().getFile().exists()) {
|
||||
event.getResource().getFile().delete();
|
||||
}
|
||||
}
|
||||
|
||||
public void addDownloadListener(DownloadListener listener) {
|
||||
this.downloadListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeDownloadListener(DownloadListener listener) {
|
||||
this.downloadListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public class MavenLibraryResolverProvider {
|
||||
return remoteRepository;
|
||||
}
|
||||
|
||||
private RemoteRepository buildRemoteRepository(MavenArtifact aritfact) {
|
||||
public static RemoteRepository buildRemoteRepository(MavenArtifact aritfact) {
|
||||
RemoteRepository repository = null;
|
||||
if (aritfact.getUsername() == null && aritfact.getPassword() == null) {
|
||||
repository = new RemoteRepository.Builder("talend", "default", aritfact.getRepositoryUrl()).build(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
@@ -277,7 +277,7 @@ public class MavenLibraryResolverProvider {
|
||||
return locator.getService(RepositorySystem.class);
|
||||
}
|
||||
|
||||
private RepositorySystemSession newSession(RepositorySystem system, String target) {
|
||||
public static RepositorySystemSession newSession(RepositorySystem system, String target) {
|
||||
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
|
||||
|
||||
LocalRepository localRepo = new LocalRepository( /* "target/local-repo" */target);
|
||||
@@ -287,7 +287,7 @@ public class MavenLibraryResolverProvider {
|
||||
return session;
|
||||
}
|
||||
|
||||
private String getLocalMVNRepository() {
|
||||
public static String getLocalMVNRepository() {
|
||||
String repository = null;
|
||||
try {
|
||||
repository = MavenPlugin.getMaven().getLocalRepositoryPath();
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.aether.util.exception;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ResolveFailedException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<Exception> exceptions;
|
||||
|
||||
public ResolveFailedException(List<Exception> exceptions) {
|
||||
super();
|
||||
this.exceptions = exceptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (exceptions != null || exceptions.size() > 0) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (Exception ex : exceptions) {
|
||||
if (ex.getLocalizedMessage() != null) {
|
||||
sb.append(ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
return super.toString();
|
||||
}
|
||||
}
|
||||
@@ -116,6 +116,12 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
@@ -93,13 +93,13 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.19</version>
|
||||
<version>1.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<archive>
|
||||
@@ -170,7 +170,7 @@
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -38,6 +38,9 @@ public class CleanMavenLastUpdateFilesLoginTask extends AbstractLoginTask {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isBackground() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -892,16 +892,31 @@ public class AggregatorPomsHelper {
|
||||
} else {
|
||||
model.getModules().addAll(collectRefProjectModules(null));
|
||||
}
|
||||
boolean isCIMode = false;
|
||||
if (IRunProcessService.get() != null) {
|
||||
isCIMode = IRunProcessService.get().isCIMode();
|
||||
}
|
||||
|
||||
createRootPom(model, true, monitor);
|
||||
installRootPom(true);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// codes pom
|
||||
monitor.subTask("Synchronize code poms"); //$NON-NLS-1$
|
||||
updateCodeProjects(monitor, true, true);
|
||||
|
||||
if (isCIMode) {
|
||||
System.setProperty("ignore.ci.mode", Boolean.TRUE.toString());
|
||||
updateCodeProjects(monitor, true, true);
|
||||
System.setProperty("ignore.ci.mode", Boolean.FALSE.toString());
|
||||
} else {
|
||||
updateCodeProjects(monitor, true, true);
|
||||
}
|
||||
|
||||
CodesJarM2CacheManager.updateCodesJarProject(monitor, true, true, true);
|
||||
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
@@ -957,6 +972,15 @@ public class AggregatorPomsHelper {
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
if (isCIMode) {
|
||||
for (ERepositoryObjectType codeType : ERepositoryObjectType.getAllTypesOfCodes()) {
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
if (codeProject != null) {
|
||||
updateCodeProjectPom(monitor, codeType, codeProject.getProjectPom());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,11 @@ public abstract class AbstractMavenCodesTemplatePom extends AbstractMavenGeneral
|
||||
existedDependencies = new ArrayList<Dependency>();
|
||||
model.setDependencies(existedDependencies);
|
||||
}
|
||||
|
||||
boolean isCIMode = false;
|
||||
if (IRunProcessService.get() != null) {
|
||||
isCIMode = IRunProcessService.get().isCIMode();
|
||||
}
|
||||
boolean ignoreCIMode = Boolean.getBoolean("ignore.ci.mode");
|
||||
for (ModuleNeeded module : needModules) {
|
||||
Dependency dependency = null;
|
||||
// TDI-37032 add dependency only if jar available in maven
|
||||
@@ -117,11 +121,8 @@ public abstract class AbstractMavenCodesTemplatePom extends AbstractMavenGeneral
|
||||
} else {
|
||||
isDeployed = true;
|
||||
}
|
||||
boolean isCIMode = false;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessService = GlobalServiceRegister.getDefault()
|
||||
.getService(IRunProcessService.class);
|
||||
isCIMode = runProcessService.isCIMode();
|
||||
if (!isDeployed && ignoreCIMode) {
|
||||
continue;
|
||||
}
|
||||
if (isCIMode || ignoreModuleInstallationStatus() || isDeployed) {
|
||||
dependency = PomUtil.createModuleDependency(module.getMavenUri());
|
||||
|
||||
@@ -655,6 +655,10 @@ public class PomUtil {
|
||||
}
|
||||
File pomFile = new File(baseFolder, TalendMavenConstants.POM_FILE_NAME);
|
||||
|
||||
return generatePomFile(pomFile, artifact);
|
||||
}
|
||||
|
||||
public static String generatePomFile(File pomFile, MavenArtifact artifact) throws Exception {
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
Model model = createModel(artifact);
|
||||
sortModules(model);
|
||||
|
||||
@@ -43,9 +43,6 @@ Export-Package: com.ctc.wstx.api,
|
||||
com.ctc.wstx.stax,
|
||||
com.ctc.wstx.sw,
|
||||
com.ctc.wstx.util,
|
||||
javax.xml.stream,
|
||||
javax.xml.stream.events,
|
||||
javax.xml.stream.util,
|
||||
org.apache.axiom.attachments,
|
||||
org.apache.axiom.attachments.impl,
|
||||
org.apache.axiom.attachments.lifecycle,
|
||||
@@ -115,7 +112,6 @@ Export-Package: com.ctc.wstx.api,
|
||||
org.apache.axis2.databinding.types.xsd,
|
||||
org.apache.axis2.databinding.utils,
|
||||
org.apache.axis2.databinding.utils.reader,
|
||||
org.apache.axis2.databinding.utils.writer,
|
||||
org.apache.axis2.dataretrieval,
|
||||
org.apache.axis2.dataretrieval.client,
|
||||
org.apache.axis2.deployment,
|
||||
@@ -133,7 +129,6 @@ Export-Package: com.ctc.wstx.api,
|
||||
org.apache.axis2.java.security,
|
||||
org.apache.axis2.jaxrs,
|
||||
org.apache.axis2.jaxws.description,
|
||||
org.apache.axis2.jsr181,
|
||||
org.apache.axis2.modules,
|
||||
org.apache.axis2.namespace,
|
||||
org.apache.axis2.phaseresolver,
|
||||
|
||||
@@ -51,7 +51,6 @@ Export-Package: org.apache.xmlbeans,
|
||||
org.apache.xmlbeans.xml.stream,
|
||||
org.apache.xmlbeans.xml.stream.events,
|
||||
org.apache.xmlbeans.xml.stream.utils,
|
||||
org.w3c.dom,
|
||||
repackage,
|
||||
schemaorg_apache_xmlbeans.system.sXMLCONFIG,
|
||||
schemaorg_apache_xmlbeans.system.sXMLLANG,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/xml-apis.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/apache-mime4j-0.6.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/castor-1.0.3.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jakarta-oro-2.0.8.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/xmlbeans-2.3.0.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -6,9 +6,7 @@ Bundle-Version: 7.4.1.qualifier
|
||||
Bundle-ClassPath: .,
|
||||
lib/apache-mime4j-0.6.jar,
|
||||
lib/castor-1.0.3.jar,
|
||||
lib/jakarta-oro-2.0.8.jar,
|
||||
lib/xmlbeans-2.3.0.jar,
|
||||
lib/xml-apis.jar
|
||||
lib/jakarta-oro-2.0.8.jar
|
||||
Bundle-Vendor: .Talend SA.
|
||||
Require-Bundle: org.apache.log4j;resolution:=optional,
|
||||
org.talend.libraries.apache.common;visibility:=reexport,
|
||||
@@ -40,52 +38,6 @@ Export-Package:
|
||||
org.apache.oro.text.perl,
|
||||
org.apache.oro.text.regex,
|
||||
org.apache.oro.util,
|
||||
org.apache.xmlbeans,
|
||||
org.apache.xmlbeans.impl.common,
|
||||
org.apache.xmlbeans.impl.config,
|
||||
org.apache.xmlbeans.impl.inst2xsd,
|
||||
org.apache.xmlbeans.impl.inst2xsd.util,
|
||||
org.apache.xmlbeans.impl.jam,
|
||||
org.apache.xmlbeans.impl.jam.annotation,
|
||||
org.apache.xmlbeans.impl.jam.internal,
|
||||
org.apache.xmlbeans.impl.jam.internal.classrefs,
|
||||
org.apache.xmlbeans.impl.jam.internal.elements,
|
||||
org.apache.xmlbeans.impl.jam.internal.javadoc,
|
||||
org.apache.xmlbeans.impl.jam.internal.parser,
|
||||
org.apache.xmlbeans.impl.jam.internal.reflect,
|
||||
org.apache.xmlbeans.impl.jam.mutable,
|
||||
org.apache.xmlbeans.impl.jam.provider,
|
||||
org.apache.xmlbeans.impl.jam.visitor,
|
||||
org.apache.xmlbeans.impl.jam.xml,
|
||||
org.apache.xmlbeans.impl.piccolo.io,
|
||||
org.apache.xmlbeans.impl.piccolo.util,
|
||||
org.apache.xmlbeans.impl.piccolo.xml,
|
||||
org.apache.xmlbeans.impl.regex,
|
||||
org.apache.xmlbeans.impl.richParser,
|
||||
org.apache.xmlbeans.impl.schema,
|
||||
org.apache.xmlbeans.impl.soap,
|
||||
org.apache.xmlbeans.impl.store,
|
||||
org.apache.xmlbeans.impl.tool,
|
||||
org.apache.xmlbeans.impl.util,
|
||||
org.apache.xmlbeans.impl.validator,
|
||||
org.apache.xmlbeans.impl.values,
|
||||
org.apache.xmlbeans.impl.xb.ltgfmt,
|
||||
org.apache.xmlbeans.impl.xb.ltgfmt.impl,
|
||||
org.apache.xmlbeans.impl.xb.substwsdl,
|
||||
org.apache.xmlbeans.impl.xb.substwsdl.impl,
|
||||
org.apache.xmlbeans.impl.xb.xmlconfig,
|
||||
org.apache.xmlbeans.impl.xb.xmlconfig.impl,
|
||||
org.apache.xmlbeans.impl.xb.xmlschema,
|
||||
org.apache.xmlbeans.impl.xb.xmlschema.impl,
|
||||
org.apache.xmlbeans.impl.xb.xsdownload,
|
||||
org.apache.xmlbeans.impl.xb.xsdownload.impl,
|
||||
org.apache.xmlbeans.impl.xb.xsdschema,
|
||||
org.apache.xmlbeans.impl.xb.xsdschema.impl,
|
||||
org.apache.xmlbeans.impl.xsd2inst,
|
||||
org.apache.xmlbeans.soap,
|
||||
org.apache.xmlbeans.xml.stream,
|
||||
org.apache.xmlbeans.xml.stream.events,
|
||||
org.apache.xmlbeans.xml.stream.utils,
|
||||
org.castor.cache,
|
||||
org.castor.cache.distributed,
|
||||
org.castor.cache.hashbelt,
|
||||
@@ -148,10 +100,6 @@ Export-Package:
|
||||
org.exolab.castor.xml.schema.writer,
|
||||
org.exolab.castor.xml.util,
|
||||
org.exolab.castor.xml.validators,
|
||||
org.exolab.castor.xml.wls8,
|
||||
schemaorg_apache_xmlbeans.system.sXMLCONFIG,
|
||||
schemaorg_apache_xmlbeans.system.sXMLLANG,
|
||||
schemaorg_apache_xmlbeans.system.sXMLSCHEMA,
|
||||
schemaorg_apache_xmlbeans.system.sXMLTOOLS
|
||||
org.exolab.castor.xml.wls8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-BundleShape: dir
|
||||
|
||||
@@ -2,8 +2,7 @@ output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
licences/,\
|
||||
lib/,\
|
||||
lib/xml-apis.jar
|
||||
lib/
|
||||
bin.excludes = libs_not_used/commons-betwixt-0.8.jar,\
|
||||
libs_not_used/commons-digester-1.7.jar,\
|
||||
libs_not_used/commons-discovery-0.2.jar,\
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -15,6 +15,7 @@ package org.talend.librariesmanager.ui.views;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.eclipse.core.text.StringMatcher;
|
||||
import org.eclipse.jface.layout.GridDataFactory;
|
||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
@@ -30,7 +31,6 @@ import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.internal.misc.StringMatcher;
|
||||
|
||||
/**
|
||||
* A TableViewer wrapper use to wrap an exist TableViewer, and provider a text field to filter item with displayed
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.utils;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -25,20 +26,17 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.ops4j.pax.url.mvn.Handler;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.general.ModuleStatusProvider;
|
||||
import org.talend.core.model.general.ModuleToInstall;
|
||||
import org.talend.librariesmanager.librarydata.LibraryDataService;
|
||||
import org.talend.librariesmanager.ui.LibManagerUiPlugin;
|
||||
import org.talend.librariesmanager.ui.i18n.Messages;
|
||||
import org.talend.librariesmanager.ui.wizards.AcceptModuleLicensesWizard;
|
||||
import org.talend.librariesmanager.ui.wizards.AcceptModuleLicensesWizardDialog;
|
||||
import org.talend.librariesmanager.utils.nexus.NexusDownloadHelperWithProgress;
|
||||
import org.talend.librariesmanager.utils.nexus.ArtifactDownloadManager;
|
||||
|
||||
abstract public class DownloadModuleRunnable implements IRunnableWithProgress {
|
||||
|
||||
@@ -93,56 +91,33 @@ abstract public class DownloadModuleRunnable implements IRunnableWithProgress {
|
||||
}
|
||||
|
||||
private void downLoad(final IProgressMonitor monitor) {
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor,
|
||||
Messages.getString("ExternalModulesInstallDialog.downloading2") + " (" + toDownload.size() + ")", //$NON-NLS-1$
|
||||
toDownload.size());
|
||||
|
||||
List<ModuleToInstall> canBeDownloadList = new ArrayList<ModuleToInstall>();
|
||||
for (final ModuleToInstall module : toDownload) {
|
||||
if (!monitor.isCanceled()) {
|
||||
monitor.subTask(module.getName());
|
||||
boolean canDownload;
|
||||
try {
|
||||
// check license
|
||||
boolean isLicenseAccepted = module.isFromCustomNexus()
|
||||
|| (LibManagerUiPlugin.getDefault().getPreferenceStore().contains(module.getLicenseType())
|
||||
&& LibManagerUiPlugin.getDefault().getPreferenceStore().getBoolean(module.getLicenseType())
|
||||
|| disableLicenseAcceptFlag);
|
||||
|
||||
canDownload = isLicenseAccepted;
|
||||
if (!canDownload) {
|
||||
subMonitor.worked(1);
|
||||
continue;
|
||||
}
|
||||
NexusDownloadHelperWithProgress downloader = new NexusDownloadHelperWithProgress(module);
|
||||
if (!module.getMavenUris().isEmpty()) {
|
||||
for (String mvnUri : module.getMavenUris()) {
|
||||
if (ELibraryInstallStatus.INSTALLED == ModuleStatusProvider.getStatus(mvnUri)) {
|
||||
continue;
|
||||
}
|
||||
downloader.download(new URL(null, mvnUri, new Handler()), null, subMonitor.newChild(1));
|
||||
|
||||
}
|
||||
} else {
|
||||
if (ELibraryInstallStatus.INSTALLED == ModuleStatusProvider.getStatus(module.getMavenUri())) {
|
||||
continue;
|
||||
}
|
||||
downloader.download(new URL(null, module.getMavenUri(), new Handler()), null, subMonitor.newChild(1));
|
||||
}
|
||||
|
||||
installedModules.add(module.getName());
|
||||
} catch (Exception e) {
|
||||
downloadFailed.add(module.getName());
|
||||
LibraryDataService.getInstance().setJarMissing(module.getMavenUri());
|
||||
Exception ex = new Exception("Download " + module.getName() + " : " + module.getMavenUri() + " failed!", e);
|
||||
ExceptionHandler.process(ex);
|
||||
continue;
|
||||
}
|
||||
canDownload = false;
|
||||
} else {
|
||||
downloadFailed.add(module.getName());
|
||||
boolean isLicenseAccepted = module.isFromCustomNexus()
|
||||
|| (LibManagerUiPlugin.getDefault().getPreferenceStore().contains(module.getLicenseType())
|
||||
&& LibManagerUiPlugin.getDefault().getPreferenceStore().getBoolean(module.getLicenseType())
|
||||
|| disableLicenseAcceptFlag);
|
||||
if (isLicenseAccepted) {
|
||||
canBeDownloadList.add(module);
|
||||
}
|
||||
}
|
||||
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
ArtifactDownloadManager downloadManager = new ArtifactDownloadManager(canBeDownloadList, monitor);
|
||||
downloadManager.start();
|
||||
List<ModuleToInstall> finishedList = downloadManager.getDownloadFinishedList();
|
||||
for (ModuleToInstall module : finishedList) {
|
||||
installedModules.add(module.getName());
|
||||
}
|
||||
Map<ModuleToInstall, Exception> failedMap = downloadManager.getDownloadFailedMap();
|
||||
for (ModuleToInstall module : failedMap.keySet()) {
|
||||
downloadFailed.add(module.getName());
|
||||
LibraryDataService.getInstance().setJarMissing(module.getMavenUri());
|
||||
Exception ex = new Exception("Download " + module.getName() + " : " + module.getMavenUri() + " failed!",
|
||||
failedMap.get(module));
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
if (showErrorInDialog && !downloadFailed.isEmpty()) {
|
||||
Exception ex = new Exception(Messages.getString("DownloadModuleRunnable.jar.download.failed",
|
||||
Arrays.toString(downloadFailed.toArray(new String[downloadFailed.size()]))));
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.utils.nexus;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.ops4j.pax.url.mvn.Handler;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.download.DownloadListener;
|
||||
import org.talend.core.download.IDownloadHelper;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.general.ModuleStatusProvider;
|
||||
import org.talend.core.model.general.ModuleToInstall;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.librariesmanager.nexus.utils.AetherArtifactDownloader;
|
||||
|
||||
public class ArtifactDownloadManager implements DownloadListener {
|
||||
|
||||
protected IProgressMonitor progressMonitor;
|
||||
|
||||
private int maxThreadNum = 10;
|
||||
|
||||
private int retryTime = 3;
|
||||
|
||||
private ThreadPoolExecutor executor;
|
||||
|
||||
private List<ModuleToInstall> moduleList = new ArrayList<ModuleToInstall>();
|
||||
|
||||
private List<ModuleToInstall> downloadFinishedList = new ArrayList<ModuleToInstall>();
|
||||
|
||||
private Map<ModuleToInstall, Exception> downloadFailedMap = new HashMap<ModuleToInstall, Exception>();
|
||||
|
||||
public ArtifactDownloadManager(List<ModuleToInstall> moduleList, IProgressMonitor progressMonitor) {
|
||||
this.moduleList = moduleList;
|
||||
this.progressMonitor = progressMonitor;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
executor = new ThreadPoolExecutor(maxThreadNum, maxThreadNum, 0, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(), new ArtifactDownloadThreadFactory());
|
||||
List<Runnable> taskList = getTasks();
|
||||
if (progressMonitor != null) {
|
||||
progressMonitor.beginTask("Downloading", taskList.size());
|
||||
}
|
||||
for (Runnable task : taskList) {
|
||||
executor.execute(task);
|
||||
}
|
||||
while (true) {
|
||||
if (executor.getTaskCount() == executor.getCompletedTaskCount()) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
}
|
||||
stop();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (!executor.isShutdown()) {
|
||||
List<Runnable> jobList = executor.shutdownNow();
|
||||
for (Runnable runnable : jobList) {
|
||||
if (runnable instanceof AbsArtifactDownLoaderRunnable) {
|
||||
this.downloadFailed(((AbsArtifactDownLoaderRunnable) runnable).getModule(),
|
||||
((AbsArtifactDownLoaderRunnable) runnable).getUrl(), new UserCanceledException("User canceled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
progressMonitor.done();
|
||||
}
|
||||
|
||||
private List<Runnable> getTasks() {
|
||||
List<Runnable> taskList = new ArrayList<Runnable>();
|
||||
for (ModuleToInstall module : moduleList) {
|
||||
if (!module.getMavenUris().isEmpty()) {
|
||||
for (String mvnUri : module.getMavenUris()) {
|
||||
if (ELibraryInstallStatus.INSTALLED == ModuleStatusProvider.getStatus(mvnUri)) {
|
||||
continue;
|
||||
}
|
||||
taskList.add(getTask(module, mvnUri));
|
||||
|
||||
}
|
||||
} else {
|
||||
if (ELibraryInstallStatus.INSTALLED == ModuleStatusProvider.getStatus(module.getMavenUri())) {
|
||||
continue;
|
||||
}
|
||||
taskList.add(getTask(module, module.getMavenUri()));
|
||||
}
|
||||
}
|
||||
return taskList;
|
||||
}
|
||||
|
||||
private Runnable getTask(ModuleToInstall module, String mvnUri) {
|
||||
ArtifactRepositoryBean serverBean = getServerFromModule(mvnUri, module.isFromCustomNexus());
|
||||
return new ArtifactDownloaderRunnable(module, mvnUri, this, serverBean);
|
||||
}
|
||||
|
||||
private ArtifactRepositoryBean getServerFromModule(String mvnUri, boolean isFromCustomNexus) {
|
||||
if (isFromCustomNexus) {
|
||||
return TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
} else {
|
||||
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(mvnUri, false);
|
||||
if (artifact != null && StringUtils.isNotEmpty(artifact.getRepositoryUrl())) {
|
||||
ArtifactRepositoryBean customNexusServer = new ArtifactRepositoryBean(false);
|
||||
customNexusServer.setServer(artifact.getRepositoryUrl());
|
||||
customNexusServer.setAbsoluteURL(true);
|
||||
String username = artifact.getUsername();
|
||||
String password = artifact.getPassword();
|
||||
if (StringUtils.isNotEmpty(username)) {
|
||||
customNexusServer.setUserName(username);
|
||||
customNexusServer.setPassword(password);
|
||||
}
|
||||
return customNexusServer;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadStart(int totalSize) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadProgress(IDownloadHelper downloader, int bytesDownloaded) {
|
||||
if (downloader != null && downloader.getDownloadingURL() != null) {
|
||||
progressMonitor.subTask(
|
||||
bytesDownloaded + "/" + downloader.getContentLength() + " : " + downloader.getDownloadingURL().getFile());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadComplete() {
|
||||
if (progressMonitor != null) {
|
||||
progressMonitor.worked(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void downloadSuccessful(ModuleToInstall module, String mvnURL) {
|
||||
downloadFinishedList.add(module);
|
||||
}
|
||||
|
||||
public void downloadFailed(ModuleToInstall module, String mvnURL, Exception ex) {
|
||||
this.downloadFailedMap.put(module, ex);
|
||||
}
|
||||
|
||||
public IProgressMonitor getProgressMonitor() {
|
||||
return progressMonitor;
|
||||
}
|
||||
|
||||
public int getRetryTime() {
|
||||
return retryTime;
|
||||
}
|
||||
|
||||
public Map<ModuleToInstall, Exception> getDownloadFailedMap() {
|
||||
return downloadFailedMap;
|
||||
}
|
||||
|
||||
public List<ModuleToInstall> getDownloadFinishedList() {
|
||||
return downloadFinishedList;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbsArtifactDownLoaderRunnable implements Runnable {
|
||||
|
||||
private static Logger logger = Logger.getLogger(AbsArtifactDownLoaderRunnable.class);
|
||||
|
||||
protected ModuleToInstall module;
|
||||
|
||||
protected String url;
|
||||
|
||||
protected ArtifactDownloadManager downloadManager;
|
||||
|
||||
AbsArtifactDownLoaderRunnable(ModuleToInstall module, String url, ArtifactDownloadManager downloadManager) {
|
||||
this.module = module;
|
||||
this.url = url;
|
||||
this.downloadManager = downloadManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int downloadTimes = 0;
|
||||
if (downloadManager.getProgressMonitor() != null && downloadManager.getProgressMonitor().isCanceled()) {
|
||||
downloadManager.downloadFailed(module, url, new UserCanceledException("User canceled"));
|
||||
if (downloadManager.getProgressMonitor() != null) {
|
||||
downloadManager.getProgressMonitor().worked(1);
|
||||
}
|
||||
downloadManager.stop();
|
||||
return;
|
||||
}
|
||||
for (; downloadTimes < downloadManager.getRetryTime(); downloadTimes++) {
|
||||
try {
|
||||
doDownLoad();
|
||||
downloadManager.downloadSuccessful(module, url);
|
||||
break;
|
||||
} catch (Exception ex) {
|
||||
if (downloadTimes < downloadManager.getRetryTime() - 1) {
|
||||
logger.warn("Download " + url + " failed, will try to download again", ex);
|
||||
} else {
|
||||
logger.error("Download " + url + " failed.", ex);
|
||||
downloadManager.downloadFailed(module, url, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void doDownLoad() throws Exception;
|
||||
|
||||
public ModuleToInstall getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
class ArtifactDownloaderRunnable extends AbsArtifactDownLoaderRunnable {
|
||||
|
||||
private ArtifactRepositoryBean serverBean;
|
||||
|
||||
ArtifactDownloaderRunnable(ModuleToInstall module, String url, ArtifactDownloadManager downloadManager,
|
||||
ArtifactRepositoryBean serverBean) {
|
||||
super(module, url, downloadManager);
|
||||
this.serverBean = serverBean;
|
||||
}
|
||||
|
||||
protected void doDownLoad() throws Exception {
|
||||
AetherArtifactDownloader downloadHelper = new AetherArtifactDownloader();
|
||||
downloadHelper.addDownloadListener(downloadManager);
|
||||
downloadHelper.setModule(getModule());
|
||||
if (serverBean != null) {
|
||||
downloadHelper.setTalendlibServer(serverBean);
|
||||
}
|
||||
downloadHelper.download(new URL(null, url, new Handler()), null);
|
||||
}
|
||||
}
|
||||
|
||||
class ArtifactDownloadThreadFactory implements ThreadFactory {
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
String name = "";
|
||||
if (r instanceof IDownloadHelper) {
|
||||
IDownloadHelper downloadHelper = (IDownloadHelper) r;
|
||||
if (downloadHelper.getDownloadingURL() != null) {
|
||||
name = downloadHelper.getDownloadingURL().getFile();
|
||||
}
|
||||
}
|
||||
String threadName = "Downloading " + name + " task";
|
||||
return new Thread(r, threadName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.librariesmanager.nexus.utils.NexusDownloader;
|
||||
import org.talend.librariesmanager.nexus.utils.AetherArtifactDownloader;
|
||||
|
||||
/**
|
||||
* created by wchen on Apr 24, 2015 Detailled comment
|
||||
@@ -110,7 +110,7 @@ public class NexusDownloadHelperWithProgress extends DownloadHelperWithProgress
|
||||
@Override
|
||||
protected IDownloadHelper createDownloadHelperDelegate(final DownloadListenerImplementation downloadProgress) {
|
||||
|
||||
NexusDownloader downloadHelper = new NexusDownloader() {
|
||||
AetherArtifactDownloader downloadHelper = new AetherArtifactDownloader() {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.utils.nexus;
|
||||
|
||||
|
||||
public class UserCanceledException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UserCanceledException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IContributor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
@@ -170,6 +170,7 @@ public class ExtensionModuleManager {
|
||||
id = moduleGroup;
|
||||
isGroup = true;
|
||||
}
|
||||
|
||||
List<ModuleNeeded> modulesNeeded = getModuleNeeded(id, isGroup);
|
||||
for (ModuleNeeded moduleNeeded : modulesNeeded) {
|
||||
String msg = importType.getMESSAGE();
|
||||
|
||||
@@ -13,32 +13,23 @@
|
||||
package org.talend.librariesmanager.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.emf.ecore.xmi.XMLResource;
|
||||
import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl;
|
||||
import org.talend.commons.exception.CommonExceptionHandler;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
@@ -53,16 +44,10 @@ import org.talend.core.ILibraryManagerUIService;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.language.LanguageManager;
|
||||
import org.talend.core.model.component_cache.ComponentCachePackage;
|
||||
import org.talend.core.model.component_cache.ComponentInfo;
|
||||
import org.talend.core.model.component_cache.ComponentsCache;
|
||||
import org.talend.core.model.component_cache.util.ComponentCacheResourceFactoryImpl;
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.ComponentManager;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.model.components.IComponentsService;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ILibrariesService.IChangedLibrariesListener;
|
||||
import org.talend.core.model.general.LibraryInfo;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
@@ -85,7 +70,6 @@ import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.core.runtime.process.TalendProcessOptionConstants;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.core.utils.CodesJarResourceCache;
|
||||
import org.talend.core.utils.TalendCacheUtils;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.model.utils.emf.component.ComponentFactory;
|
||||
import org.talend.designer.core.model.utils.emf.component.IMPORTType;
|
||||
@@ -95,6 +79,7 @@ import org.talend.librariesmanager.model.service.CustomUriManager;
|
||||
import org.talend.librariesmanager.model.service.LibrariesIndexManager;
|
||||
import org.talend.librariesmanager.prefs.LibrariesManagerUtils;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.documentation.ExportFileResource;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
|
||||
@@ -124,10 +109,6 @@ public class ModulesNeededProvider {
|
||||
|
||||
private static boolean cleanDone = false;
|
||||
|
||||
private static final String TALEND_COMPONENT_CACHE = "ComponentsCache.";
|
||||
|
||||
private static final String TALEND_FILE_NAME = "cache";
|
||||
|
||||
private static final List<IChangedLibrariesListener> listeners = new ArrayList<>();
|
||||
|
||||
private static IRepositoryService repositoryService = null;
|
||||
@@ -262,8 +243,8 @@ public class ModulesNeededProvider {
|
||||
|
||||
public static Set<String> getAllModuleNamesFromIndex() {
|
||||
Set<String> moduleNames = new HashSet<String>();
|
||||
moduleNames.addAll(LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath().keySet());
|
||||
moduleNames.addAll(LibrariesIndexManager.getInstance().getStudioLibIndex().getJarsToRelativePath().keySet());
|
||||
moduleNames.addAll(LibrariesIndexManager.getInstance().getAllMavenLibsFromIndex().keySet());
|
||||
moduleNames.addAll(LibrariesIndexManager.getInstance().getAllStudioLibsFromIndex().keySet());
|
||||
return moduleNames;
|
||||
}
|
||||
|
||||
@@ -278,8 +259,8 @@ public class ModulesNeededProvider {
|
||||
public static void reset() {
|
||||
// clean the cache
|
||||
ExtensionModuleManager.getInstance().clearCache();
|
||||
getModulesNeeded().clear();
|
||||
getAllManagedModules().clear();
|
||||
componentImportNeedsList.clear();
|
||||
allManagedModules.clear();
|
||||
systemModules = null;
|
||||
}
|
||||
|
||||
@@ -305,6 +286,7 @@ public class ModulesNeededProvider {
|
||||
for (ModuleNeeded neededLibrary : neededLibraries) {
|
||||
boolean alreadyInImports = false;
|
||||
for (ModuleNeeded module : getModulesNeeded()) {
|
||||
if (module == null) continue;
|
||||
if (module != null && module.getModuleName() != null
|
||||
&& module.getModuleName().equals(neededLibrary.getModuleName())) {
|
||||
if (StringUtils.equals(module.getMavenUri(), neededLibrary.getMavenUri())) {
|
||||
@@ -338,47 +320,12 @@ public class ModulesNeededProvider {
|
||||
}
|
||||
|
||||
private static List<ModuleNeeded> getModulesNeededForComponents() {
|
||||
initCache();
|
||||
if (isCreated) {
|
||||
List<ModuleNeeded> importNeedsList = new ArrayList<ModuleNeeded>();
|
||||
ComponentsCache cache = ComponentManager.getComponentCache();
|
||||
EMap<String, EList<ComponentInfo>> map = cache.getComponentEntryMap();
|
||||
Set<String> set = map.keySet();
|
||||
Iterator it = set.iterator();
|
||||
Map<String, Boolean> bundlesAvailable = new HashMap<String, Boolean>();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
EList<ComponentInfo> value = map.get(key);
|
||||
for (ComponentInfo info : value) {
|
||||
Boolean available = bundlesAvailable.get(info.getSourceBundleName());
|
||||
if (available == null) {
|
||||
available = Platform.getBundle(info.getSourceBundleName()) != null;
|
||||
bundlesAvailable.put(info.getSourceBundleName(), available);
|
||||
}
|
||||
if (!available) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EList emfImportList = info.getImportType();
|
||||
for (int i = 0; i < emfImportList.size(); i++) {
|
||||
IMPORTType importType = (IMPORTType) emfImportList.get(i);
|
||||
collectModuleNeeded(key, importType, importNeedsList);
|
||||
}
|
||||
}
|
||||
}
|
||||
return importNeedsList;
|
||||
} else {
|
||||
List<ModuleNeeded> importNeedsList = new ArrayList<ModuleNeeded>();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsService.class)) {
|
||||
IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault()
|
||||
.getService(IComponentsService.class);
|
||||
IComponentsFactory compFac = service.getComponentsFactory();
|
||||
for (IComponent comp : compFac.readComponents()) {
|
||||
importNeedsList.addAll(comp.getModulesNeeded());
|
||||
}
|
||||
}
|
||||
return importNeedsList;
|
||||
IComponentsService componentService = IComponentsService.get();
|
||||
if (componentService == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return componentService.getComponentsFactory().readComponents().stream().flatMap(comp -> comp.getModulesNeeded().stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void collectModuleNeeded(String context, IMPORTType importType, List<ModuleNeeded> importNeedsList) {
|
||||
@@ -392,15 +339,6 @@ public class ModulesNeededProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean createModuleNeededForComponentFromExtension(String context, IMPORTType importType,
|
||||
List<ModuleNeeded> importNeedsList) {
|
||||
List<ModuleNeeded> importModuleNeeded = ExtensionModuleManager.getInstance().getModuleNeededForComponent(context,
|
||||
importType);
|
||||
importNeedsList.addAll(importModuleNeeded);
|
||||
|
||||
return importModuleNeeded.size() > 0;
|
||||
}
|
||||
|
||||
public static void createModuleNeededForComponent(String context, IMPORTType importType, List<ModuleNeeded> importNeedsList) {
|
||||
if (importType.getMODULE() == null) {
|
||||
if (importType.getMODULEGROUP() != null) {
|
||||
@@ -450,53 +388,6 @@ public class ModulesNeededProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private static void initCache() {
|
||||
String installLocation = new Path(Platform.getConfigurationLocation().getURL().getPath()).toFile().getAbsolutePath();
|
||||
boolean isNeedClean = !cleanDone && TalendCacheUtils.isSetCleanComponentCache();
|
||||
cleanDone = true;
|
||||
isCreated = hasComponentFile(installLocation) && !isNeedClean;
|
||||
ComponentsCache cache = ComponentManager.getComponentCache();
|
||||
try {
|
||||
if (isCreated) {
|
||||
if (cache.getComponentEntryMap().isEmpty()) {
|
||||
ComponentsCache loadCache = loadComponentResource(installLocation);
|
||||
cache.getComponentEntryMap().putAll(loadCache.getComponentEntryMap());
|
||||
}
|
||||
} else {
|
||||
cache.getComponentEntryMap().clear();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
cache.getComponentEntryMap().clear();
|
||||
isCreated = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasComponentFile(String installLocation) {
|
||||
String filePath = ModulesNeededProvider.TALEND_COMPONENT_CACHE
|
||||
+ LanguageManager.getCurrentLanguage().toString().toLowerCase() + ModulesNeededProvider.TALEND_FILE_NAME;
|
||||
File file = new File(new Path(installLocation).append(filePath).toString());
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
private static ComponentsCache loadComponentResource(String installLocation) throws IOException {
|
||||
String filePath = ModulesNeededProvider.TALEND_COMPONENT_CACHE
|
||||
+ LanguageManager.getCurrentLanguage().toString().toLowerCase() + ModulesNeededProvider.TALEND_FILE_NAME;
|
||||
URI uri = URI.createFileURI(installLocation).appendSegment(filePath);
|
||||
ComponentCacheResourceFactoryImpl compFact = new ComponentCacheResourceFactoryImpl();
|
||||
Resource resource = compFact.createResource(uri);
|
||||
Map optionMap = new HashMap();
|
||||
optionMap.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
|
||||
optionMap.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
|
||||
optionMap.put(XMLResource.OPTION_USE_PARSER_POOL, new XMLParserPoolImpl());
|
||||
optionMap.put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, new HashMap());
|
||||
optionMap.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE);
|
||||
resource.load(optionMap);
|
||||
ComponentsCache cache = (ComponentsCache) EcoreUtil.getObjectByType(resource.getContents(),
|
||||
ComponentCachePackage.eINSTANCE.getComponentsCache());
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@@ -521,7 +412,7 @@ public class ModulesNeededProvider {
|
||||
if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(process.getComponentsType())) {
|
||||
// route do not save any relationship with beans , so add all for now
|
||||
modulesNeeded.addAll(getCodesModuleNeededs(ERepositoryObjectType.BEANS));
|
||||
modulesNeeded.addAll(getModulesNeededForRoutes());
|
||||
modulesNeeded.addAll(getModulesNeededForRoutes(processItem));
|
||||
}
|
||||
return modulesNeeded;
|
||||
}
|
||||
@@ -782,15 +673,26 @@ public class ModulesNeededProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<ModuleNeeded> getModulesNeededForRoutes() {
|
||||
/**
|
||||
* DOC sunchaoqun Comment method "getModulesNeededForRoutes".
|
||||
*
|
||||
* @param processes
|
||||
* @return
|
||||
*/
|
||||
private static List<ModuleNeeded> getModulesNeededForRoutes(ProcessItem processItem) {
|
||||
ILibrariesService service = null;
|
||||
if (!GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
return null;
|
||||
}
|
||||
service = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
|
||||
|
||||
if (importNeedsListForRoutes == null) {
|
||||
|
||||
importNeedsListForRoutes = new ArrayList<ModuleNeeded>();
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "camel-core"));
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "camel-spring"));
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "spring-context"));
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "spring-beans"));
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "spring-core"));
|
||||
|
||||
importNeedsListForRoutes.addAll(service.getModuleNeeded("camel-core", true));
|
||||
importNeedsListForRoutes.addAll(service.getModuleNeeded("camel-spring", true));
|
||||
|
||||
if (System.getProperty("java.version") != null && System.getProperty("java.version").startsWith("11")) {
|
||||
getModulesNeededForRoutesJava11();
|
||||
}
|
||||
@@ -800,9 +702,16 @@ public class ModulesNeededProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
importNeedsListForRoutes.removeIf(m-> (m==null));
|
||||
|
||||
return importNeedsListForRoutes;
|
||||
}
|
||||
|
||||
public static List<ModuleNeeded> getModulesNeededForRoutes() {
|
||||
return getModulesNeededForRoutes(null);
|
||||
}
|
||||
|
||||
private static void getModulesNeededForRoutesJava11() {
|
||||
/**
|
||||
* importNeedsListForRoutes.add(getModuleNeededForName("istack-commons-runtime-3.0.8.jar"));
|
||||
@@ -838,9 +747,22 @@ public class ModulesNeededProvider {
|
||||
}
|
||||
|
||||
public static List<ModuleNeeded> getModulesNeededForBeans() {
|
||||
return getModulesNeededForBeans(null);
|
||||
}
|
||||
|
||||
public static List<ModuleNeeded> getModulesNeededForBeans(ExportFileResource[] processes) {
|
||||
ProcessItem processItem = null;
|
||||
if (processes != null && processes.length > 0) {
|
||||
if (processes[0].getItem() instanceof ProcessItem) {
|
||||
processItem = (ProcessItem) processes[0].getItem();
|
||||
}
|
||||
}
|
||||
|
||||
if (importNeedsListForBeans == null) {
|
||||
importNeedsListForBeans = getModulesNeededForRoutes();
|
||||
importNeedsListForBeans = getModulesNeededForRoutes(processItem);
|
||||
|
||||
importNeedsListForBeans.add(getComponentModuleById("CAMEL", "camel-cxf"));
|
||||
|
||||
importNeedsListForBeans.add(getComponentModuleById("CAMEL", "cxf-core"));
|
||||
importNeedsListForBeans.add(getComponentModuleById("CAMEL", "javax.ws.rs-api"));
|
||||
for (ModuleNeeded need : importNeedsListForBeans) {
|
||||
@@ -1048,7 +970,7 @@ public class ModulesNeededProvider {
|
||||
List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>(getModulesNeeded());
|
||||
List<ModuleNeeded> uninstalledModules = new ArrayList<ModuleNeeded>(modulesNeeded.size());
|
||||
for (ModuleNeeded module : modulesNeeded) {
|
||||
if (module.getStatus() == ELibraryInstallStatus.NOT_INSTALLED) {
|
||||
if (module.getStatus() == ELibraryInstallStatus.NOT_INSTALLED && !module.usedByDynamicDistribution()) {
|
||||
uninstalledModules.add(module);
|
||||
} // else installed or unknow state so ignor.
|
||||
}
|
||||
|
||||
@@ -229,7 +229,6 @@ public abstract class AbstractLibrariesService implements ILibrariesService {
|
||||
public void resetModulesNeeded() {
|
||||
ModulesNeededProvider.reset();
|
||||
ModuleStatusProvider.reset();
|
||||
ModulesNeededProvider.getModulesNeeded().clear();
|
||||
checkLibraries();
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,6 @@ public class JavaLibrariesService extends AbstractLibrariesService {
|
||||
if (!repositoryBundleService.isInitialized()) {
|
||||
// 2. Components libraries and libraries from extension
|
||||
repositoryBundleService.createModulesIndexFromComponentAndExtension(monitorWrap);
|
||||
repositoryBundleService.setInitialized();
|
||||
}
|
||||
|
||||
repositoryBundleService.installModules(ModulesNeededProvider.getSystemRunningModules(), null);
|
||||
|
||||
@@ -14,9 +14,12 @@ package org.talend.librariesmanager.model.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
@@ -45,6 +48,12 @@ public class LibrariesIndexManager {
|
||||
|
||||
private static final String MAVEN_INDEX = "MavenUriIndex.xml";
|
||||
|
||||
private ReentrantReadWriteLock studioLibLock = new ReentrantReadWriteLock();
|
||||
|
||||
private ReentrantReadWriteLock mavenLibLock = new ReentrantReadWriteLock();
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(LibrariesIndexManager.class);
|
||||
|
||||
private LibrariesIndexManager() {
|
||||
loadIndexResources();
|
||||
}
|
||||
@@ -53,8 +62,9 @@ public class LibrariesIndexManager {
|
||||
return manager;
|
||||
}
|
||||
|
||||
private synchronized void loadIndexResources() {
|
||||
private void loadIndexResources() {
|
||||
try {
|
||||
studioLibLock.writeLock().lock();
|
||||
if (!new File(getStudioIndexPath()).exists()) {
|
||||
studioLibIndex = LibrariesindexFactory.eINSTANCE.createLibrariesIndex();
|
||||
} else {
|
||||
@@ -70,6 +80,13 @@ public class LibrariesIndexManager {
|
||||
LibrariesindexPackage.eINSTANCE.getLibrariesIndex());
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
CommonExceptionHandler.process(e);
|
||||
} finally {
|
||||
studioLibLock.writeLock().unlock();
|
||||
}
|
||||
try {
|
||||
mavenLibLock.writeLock().lock();
|
||||
if (!new File(getMavenIndexPath()).exists()) {
|
||||
mavenLibIndex = LibrariesindexFactory.eINSTANCE.createLibrariesIndex();
|
||||
} else {
|
||||
@@ -87,16 +104,45 @@ public class LibrariesIndexManager {
|
||||
|
||||
} catch (IOException e) {
|
||||
CommonExceptionHandler.process(e);
|
||||
} finally {
|
||||
mavenLibLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStudioIndexResource() {
|
||||
saveResource(studioLibIndex, LIBRARIES_INDEX);
|
||||
try {
|
||||
studioLibLock.writeLock().lock();
|
||||
saveResource(studioLibIndex, LIBRARIES_INDEX);
|
||||
} finally {
|
||||
studioLibLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void setStudioIndexInitialized(boolean init) {
|
||||
studioLibLock.writeLock().lock();
|
||||
try {
|
||||
studioLibIndex.setInitialized(init);
|
||||
} finally {
|
||||
studioLibLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMavenIndexInitialized(boolean init) {
|
||||
mavenLibLock.writeLock().lock();
|
||||
try {
|
||||
mavenLibIndex.setInitialized(true);
|
||||
} finally {
|
||||
mavenLibLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveMavenIndexResource() {
|
||||
saveResource(mavenLibIndex, MAVEN_INDEX);
|
||||
try {
|
||||
mavenLibLock.writeLock().lock();
|
||||
saveResource(mavenLibIndex, MAVEN_INDEX);
|
||||
} finally {
|
||||
mavenLibLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveResource(EObject eObject, String fileName) {
|
||||
@@ -111,15 +157,25 @@ public class LibrariesIndexManager {
|
||||
}
|
||||
|
||||
public void clearAll() {
|
||||
if (studioLibIndex != null) {
|
||||
studioLibIndex.setInitialized(false);
|
||||
studioLibIndex.getJarsToRelativePath().clear();
|
||||
saveStudioIndexResource();
|
||||
try {
|
||||
studioLibLock.writeLock().lock();
|
||||
if (studioLibIndex != null) {
|
||||
studioLibIndex.setInitialized(false);
|
||||
studioLibIndex.getJarsToRelativePath().clear();
|
||||
saveStudioIndexResource();
|
||||
}
|
||||
} finally {
|
||||
studioLibLock.writeLock().unlock();
|
||||
}
|
||||
if (mavenLibIndex != null) {
|
||||
mavenLibIndex.setInitialized(false);
|
||||
mavenLibIndex.getJarsToRelativePath().clear();
|
||||
saveMavenIndexResource();
|
||||
try {
|
||||
mavenLibLock.writeLock().lock();
|
||||
if (mavenLibIndex != null) {
|
||||
mavenLibIndex.setInitialized(false);
|
||||
mavenLibIndex.getJarsToRelativePath().clear();
|
||||
saveMavenIndexResource();
|
||||
}
|
||||
} finally {
|
||||
mavenLibLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,19 +197,6 @@ public class LibrariesIndexManager {
|
||||
return new Path(getIndexFileInstallFolder()).append(MAVEN_INDEX).toFile().getAbsolutePath();
|
||||
}
|
||||
|
||||
public LibrariesIndex getStudioLibIndex() {
|
||||
return studioLibIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for mavenLibIndex.
|
||||
*
|
||||
* @return the mavenLibIndex
|
||||
*/
|
||||
public LibrariesIndex getMavenLibIndex() {
|
||||
return this.mavenLibIndex;
|
||||
}
|
||||
|
||||
public String getMvnUriFromIndex(String jarName) {
|
||||
if (mavenLibIndex != null) {
|
||||
return this.mavenLibIndex.getJarsToRelativePath().get(jarName);
|
||||
@@ -162,4 +205,82 @@ public class LibrariesIndexManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all contents inside studio lib index file, return as unmodifiable map
|
||||
*/
|
||||
public Map<String, String> getAllStudioLibsFromIndex() {
|
||||
this.studioLibLock.readLock().lock();
|
||||
try {
|
||||
return Collections.unmodifiableMap(this.studioLibIndex.getJarsToRelativePath().map());
|
||||
} finally {
|
||||
this.studioLibLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to studio lib without saving
|
||||
*/
|
||||
public void AddStudioLibs(String key, String v) {
|
||||
this.studioLibLock.writeLock().lock();
|
||||
try {
|
||||
this.studioLibIndex.getJarsToRelativePath().put(key, v);
|
||||
} finally {
|
||||
this.studioLibLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* whether contains key
|
||||
*/
|
||||
public boolean containsStudioLibs(String key) {
|
||||
this.studioLibLock.readLock().lock();
|
||||
try {
|
||||
return this.studioLibIndex.getJarsToRelativePath().containsKey(key);
|
||||
} finally {
|
||||
this.studioLibLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all contents inside maven lib index file, return as unmodifiable map
|
||||
*/
|
||||
public Map<String, String> getAllMavenLibsFromIndex() {
|
||||
this.mavenLibLock.readLock().lock();
|
||||
try {
|
||||
return Collections.unmodifiableMap(this.mavenLibIndex.getJarsToRelativePath().map());
|
||||
} finally {
|
||||
this.mavenLibLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to maven lib without saving
|
||||
*/
|
||||
public void AddMavenLibs(String key, String v) {
|
||||
this.mavenLibLock.writeLock().lock();
|
||||
try {
|
||||
this.mavenLibIndex.getJarsToRelativePath().put(key, v);
|
||||
} finally {
|
||||
this.mavenLibLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStudioLibInitialized() {
|
||||
this.studioLibLock.readLock().lock();
|
||||
try {
|
||||
return this.studioLibIndex.isInitialized();
|
||||
} finally {
|
||||
this.studioLibLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMavenLibInitialized() {
|
||||
this.mavenLibLock.readLock().lock();
|
||||
try {
|
||||
return this.mavenLibIndex.isInitialized();
|
||||
} finally {
|
||||
this.mavenLibLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
@@ -45,7 +46,6 @@ import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.ConfigurationScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
@@ -145,19 +145,12 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
File indexFile = new File(LibrariesIndexManager.getInstance().getStudioIndexPath());
|
||||
File mvnIndexFile = new File(LibrariesIndexManager.getInstance().getMavenIndexPath());
|
||||
if (indexFile.exists() && mvnIndexFile.exists()) {
|
||||
return LibrariesIndexManager.getInstance().getStudioLibIndex().isInitialized();
|
||||
return LibrariesIndexManager.getInstance().isStudioLibInitialized()
|
||||
&& LibrariesIndexManager.getInstance().isMavenLibInitialized();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInitialized() {
|
||||
LibrariesIndexManager.getInstance().getStudioLibIndex().setInitialized(true);
|
||||
LibrariesIndexManager.getInstance().saveStudioIndexResource();
|
||||
LibrariesIndexManager.getInstance().getMavenLibIndex().setInitialized(true);
|
||||
LibrariesIndexManager.getInstance().saveMavenIndexResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deploy(URI jarFileUri, IProgressMonitor... monitorWrap) {
|
||||
deploy(jarFileUri, null, monitorWrap);
|
||||
@@ -257,7 +250,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
private void guessMavenRUIFromIndex(File jarFile, boolean useReleaseVersion, Map<String, String> sourceAndMavenUri) {
|
||||
// TODO????? should deploy with all versions
|
||||
String urisFromIndex = LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath()
|
||||
String urisFromIndex = LibrariesIndexManager.getInstance().getAllMavenLibsFromIndex()
|
||||
.get(jarFile.getName());
|
||||
boolean deployAsDefault = true;
|
||||
if (urisFromIndex != null) {
|
||||
@@ -455,7 +448,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
|
||||
private Set<String> guessMavenURI(ModuleNeeded module) {
|
||||
String jarNeeded = module.getModuleName();
|
||||
EMap<String, String> mvnURIIndex = LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath();
|
||||
Map<String, String> mvnURIIndex = LibrariesIndexManager.getInstance().getAllMavenLibsFromIndex();
|
||||
Set<String> toResolve = new HashSet<>();
|
||||
if (module.getCustomMavenUri() != null) {
|
||||
toResolve.add(module.getCustomMavenUri());
|
||||
@@ -862,7 +855,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
@Override
|
||||
public void installModules(Collection<ModuleNeeded> modules, IProgressMonitor monitorWrap) {
|
||||
EMap<String, String> libIndex = LibrariesIndexManager.getInstance().getStudioLibIndex().getJarsToRelativePath();
|
||||
Map<String, String> libIndex = LibrariesIndexManager.getInstance().getAllStudioLibsFromIndex();
|
||||
for (ModuleNeeded module : modules) {
|
||||
File fileToDeploy = null;
|
||||
String moduleLocation = module.getModuleLocaion();
|
||||
@@ -891,8 +884,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
EMap<String, String> jarsToRelative = LibrariesIndexManager.getInstance().getStudioLibIndex()
|
||||
.getJarsToRelativePath();
|
||||
Map<String, String> jarsToRelative = LibrariesIndexManager.getInstance().getAllStudioLibsFromIndex();
|
||||
String relativePath = jarsToRelative.get(module.getModuleName());
|
||||
if (relativePath != null && checkJarInstalledFromPlatform(relativePath)) {
|
||||
found = true;
|
||||
@@ -950,7 +942,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
libPath = file.getAbsolutePath();
|
||||
}
|
||||
// studio
|
||||
EMap<String, String> jarsToRelative = LibrariesIndexManager.getInstance().getStudioLibIndex().getJarsToRelativePath();
|
||||
Map<String, String> jarsToRelative = LibrariesIndexManager.getInstance().getAllStudioLibsFromIndex();
|
||||
String relativePath = jarsToRelative.get(jarName);
|
||||
if (relativePath != null && relativePath.startsWith("platform:/")) { //$NON-NLS-1$
|
||||
boolean jarFound = checkJarInstalledFromPlatform(relativePath);
|
||||
@@ -1266,6 +1258,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsService.class)) {
|
||||
service = GlobalServiceRegister.getDefault().getService(IComponentsService.class);
|
||||
}
|
||||
|
||||
if (service != null) {
|
||||
for (IComponent component : service.getComponentsFactory().readComponents()) {
|
||||
try {
|
||||
@@ -1276,6 +1269,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calculateModulesIndex(modules, platformURLMap, duplicateLocationJar, mavenURIMap, duplicateMavenUri);
|
||||
|
||||
calculateModulesIndexFromExtension(platformURLMap, duplicateLocationJar, mavenURIMap, duplicateMavenUri);
|
||||
@@ -1293,6 +1287,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
calculateModulesIndexFromComponentFolder(service, platformURLMap);
|
||||
}
|
||||
|
||||
// all of contents will be inside
|
||||
saveMavenIndex(mavenURIMap, monitorWrap);
|
||||
savePlatfromURLIndex(platformURLMap, monitorWrap);
|
||||
|
||||
@@ -1527,15 +1522,18 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
@Override
|
||||
public void savePlatfromURLIndex(Map<String, String> libsToRelativePath, IProgressMonitor... monitorWrap) {
|
||||
EMap<String, String> jarsToRelative = LibrariesIndexManager.getInstance().getStudioLibIndex().getJarsToRelativePath();
|
||||
boolean modified = false;
|
||||
for (String key : libsToRelativePath.keySet()) {
|
||||
if (checkJarInstalledFromPlatform(libsToRelativePath.get(key))) {
|
||||
jarsToRelative.put(key, libsToRelativePath.get(key));
|
||||
modified = true;
|
||||
Set<Entry<String, String>> entries = libsToRelativePath.entrySet();
|
||||
for (Entry<String, String> entry : entries) {
|
||||
if (!LibrariesIndexManager.getInstance().containsStudioLibs(entry.getKey())) {
|
||||
if (checkJarInstalledFromPlatform(entry.getValue())) {
|
||||
LibrariesIndexManager.getInstance().AddStudioLibs(entry.getKey(), entry.getValue());
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (modified) {
|
||||
LibrariesIndexManager.getInstance().setStudioIndexInitialized(true);
|
||||
LibrariesIndexManager.getInstance().saveStudioIndexResource();
|
||||
}
|
||||
}
|
||||
@@ -1548,19 +1546,20 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
@Override
|
||||
public void saveMavenIndex(Map<String, String> libsMavenUriToDeploy, IProgressMonitor... monitorWrap) {
|
||||
EMap<String, String> jarsToMavenuri = LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath();
|
||||
Map<String, String> jarsToMavenuri = LibrariesIndexManager.getInstance().getAllMavenLibsFromIndex();
|
||||
boolean modified = false;
|
||||
for (String key : libsMavenUriToDeploy.keySet()) {
|
||||
String mvnUri = libsMavenUriToDeploy.get(key);
|
||||
Set<Entry<String,String>> entries = libsMavenUriToDeploy.entrySet();
|
||||
for (Entry<String,String> entry : entries) {
|
||||
String key = entry.getKey();
|
||||
String mvnUri = entry.getValue();
|
||||
if (!jarsToMavenuri.containsKey(key)
|
||||
|| mvnUri != null && jarsToMavenuri.containsKey(key) && !mvnUri.equals(jarsToMavenuri.get(key))) {
|
||||
|| (mvnUri != null && jarsToMavenuri.containsKey(key) && !mvnUri.equals(jarsToMavenuri.get(key)))) {
|
||||
String valueFromIndex = jarsToMavenuri.get(key);
|
||||
if (valueFromIndex == null) {
|
||||
jarsToMavenuri.put(key, mvnUri);
|
||||
LibrariesIndexManager.getInstance().AddMavenLibs(key, mvnUri);
|
||||
modified = true;
|
||||
} else {
|
||||
// merge the two mvnuri value if needed
|
||||
String newUri = mvnUri;
|
||||
final String[] indexUris = valueFromIndex.split(MavenUrlHelper.MVN_INDEX_SPLITER);
|
||||
final String[] toDeployUris = mvnUri.split(MavenUrlHelper.MVN_INDEX_SPLITER);
|
||||
for (String indexUri : indexUris) {
|
||||
@@ -1574,12 +1573,13 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
mvnUri = mvnUri + MavenUrlHelper.MVN_INDEX_SEPARATOR + indexUri;
|
||||
}
|
||||
}
|
||||
jarsToMavenuri.put(key, newUri);
|
||||
LibrariesIndexManager.getInstance().AddMavenLibs(key, mvnUri);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (modified) {
|
||||
LibrariesIndexManager.getInstance().setMavenIndexInitialized(true);
|
||||
LibrariesIndexManager.getInstance().saveMavenIndexResource();
|
||||
}
|
||||
}
|
||||
@@ -1651,7 +1651,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
@Override
|
||||
public String getMavenUriFromIndex(String jarName) {
|
||||
EMap<String, String> jarsToMavenuri = LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath();
|
||||
Map<String, String> jarsToMavenuri = LibrariesIndexManager.getInstance().getAllMavenLibsFromIndex();
|
||||
return jarsToMavenuri.get(jarName);
|
||||
}
|
||||
|
||||
@@ -1692,7 +1692,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
@Override
|
||||
public String getPlatformURLFromIndex(String jarName) {
|
||||
EMap<String, String> platformURLMap = LibrariesIndexManager.getInstance().getStudioLibIndex().getJarsToRelativePath();
|
||||
Map<String, String> platformURLMap = LibrariesIndexManager.getInstance().getAllStudioLibsFromIndex();
|
||||
return platformURLMap.get(jarName);
|
||||
}
|
||||
|
||||
@@ -1817,7 +1817,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
|
||||
@Override
|
||||
public String getJarNameFromMavenuri(String mavenURI) {
|
||||
EMap<String, String> jarsToMavenuri = LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath();
|
||||
Map<String, String> jarsToMavenuri = LibrariesIndexManager.getInstance().getAllMavenLibsFromIndex();
|
||||
for (String key : jarsToMavenuri.keySet()) {
|
||||
if (jarsToMavenuri.get(key) == null) {
|
||||
continue;
|
||||
|
||||
@@ -14,9 +14,9 @@ package org.talend.librariesmanager.nexus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -24,14 +24,17 @@ import java.util.List;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpHeaders;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.fluent.Request;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.network.IProxySelectorProvider;
|
||||
@@ -55,6 +58,8 @@ import net.sf.json.JSONObject;
|
||||
*/
|
||||
public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(ArtifacoryRepositoryHandler.class);
|
||||
|
||||
private String SEARCH_SERVICE = "api/search/gavc?"; //$NON-NLS-1$
|
||||
|
||||
private static final String SEARCH_NAME = "api/search/artifact?";
|
||||
@@ -199,18 +204,9 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
}
|
||||
query = query + "v=" + versionToSearch;//$NON-NLS-1$
|
||||
}
|
||||
searchUrl = searchUrl + query;
|
||||
Request request = Request.Get(searchUrl);
|
||||
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword(); //$NON-NLS-1$
|
||||
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes())); //$NON-NLS-1$
|
||||
Header authority = new BasicHeader("Authorization", basicAuth); //$NON-NLS-1$
|
||||
request.addHeader(authority);
|
||||
Header resultDetailHeader = new BasicHeader("X-Result-Detail", "info"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
request.addHeader(resultDetailHeader);
|
||||
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
|
||||
|
||||
HttpResponse response = request.execute().returnResponse();
|
||||
String content = EntityUtils.toString(response.getEntity());
|
||||
searchUrl = searchUrl + query;
|
||||
String content = doRequest(searchUrl);//
|
||||
if (content.isEmpty()) {
|
||||
return resultList;
|
||||
}
|
||||
@@ -307,19 +303,9 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
}
|
||||
q += "repos=" + repositoryId;//$NON-NLS-1$
|
||||
}
|
||||
|
||||
searchUrl = searchUrl + q;
|
||||
Request request = Request.Get(searchUrl);
|
||||
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword(); //$NON-NLS-1$
|
||||
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes())); //$NON-NLS-1$
|
||||
Header authority = new BasicHeader("Authorization", basicAuth); //$NON-NLS-1$
|
||||
request.addHeader(authority);
|
||||
Header resultDetailHeader = new BasicHeader("X-Result-Detail", "info"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
request.addHeader(resultDetailHeader);
|
||||
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
|
||||
|
||||
HttpResponse response = request.execute().returnResponse();
|
||||
String content = EntityUtils.toString(response.getEntity());
|
||||
searchUrl = searchUrl + q;
|
||||
String content = doRequest(searchUrl);//
|
||||
if (content.isEmpty()) {
|
||||
return resultList;
|
||||
}
|
||||
@@ -498,4 +484,34 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
return doSearch(query, SEARCH_NAME, true, fromSnapshot);
|
||||
}
|
||||
|
||||
public String doRequest(final String url) throws URISyntaxException, Exception {
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
new HttpClientTransport(url, serverBean.getUserName(), serverBean.getPassword()) {
|
||||
|
||||
@Override
|
||||
protected HttpResponse execute(IProgressMonitor monitor, DefaultHttpClient httpClient, URI targetURI)
|
||||
throws Exception {
|
||||
HttpGet httpGet = new HttpGet(targetURI);
|
||||
String userName = serverBean.getUserName();
|
||||
if (StringUtils.isNotBlank(userName) && !Boolean.getBoolean("talend.studio.search.nexus3.disableBasicAuth")) {
|
||||
String auth = userName + ":" + serverBean.getPassword();
|
||||
String authHeader = "Basic " + new String(Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8)));
|
||||
httpGet.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
|
||||
Header resultDetailHeader = new BasicHeader("X-Result-Detail", "info"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
httpGet.addHeader(resultDetailHeader);
|
||||
httpClient.setCredentialsProvider(null);
|
||||
}
|
||||
HttpResponse response = httpClient.execute(httpGet);
|
||||
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
sb.append(EntityUtils.toString(response.getEntity()));
|
||||
} else {
|
||||
LOGGER.info("Try to search " + url + " failed!");
|
||||
throw new Exception(response.toString());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}.doRequest(null, new URI(url));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.nexus.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.talend.core.download.DownloadListener;
|
||||
import org.talend.core.download.IDownloadHelper;
|
||||
import org.talend.core.model.general.ModuleStatusProvider;
|
||||
import org.talend.core.model.general.ModuleToInstall;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.designer.maven.aether.util.AetherArtifactDownloadProvider;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.librariesmanager.maven.MavenArtifactsHandler;
|
||||
|
||||
public class AetherArtifactDownloader implements IDownloadHelper, DownloadListener {
|
||||
|
||||
private List<DownloadListener> fListeners = new ArrayList<DownloadListener>();
|
||||
|
||||
private boolean fCancel = false;
|
||||
|
||||
private ArtifactRepositoryBean nexusServer;
|
||||
|
||||
private URL downloadingURL = null;
|
||||
|
||||
private long contentLength = -1l;
|
||||
|
||||
private File resolvedFile = null;
|
||||
|
||||
private ModuleToInstall module;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.download.IDownloadHelper#download(java.net.URL, java.io.File)
|
||||
*/
|
||||
@Override
|
||||
public void download(URL url, File desc) throws Exception {
|
||||
this.downloadingURL = url;
|
||||
String mavenUri = url.toExternalForm();
|
||||
MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(mavenUri);
|
||||
if (parseMvnUrl != null) {
|
||||
ArtifactRepositoryBean nServer = getNexusServer();
|
||||
AetherArtifactDownloadProvider resolver = new AetherArtifactDownloadProvider();
|
||||
resolver.addDownloadListener(this);
|
||||
try {
|
||||
resolvedFile = resolver.resolveArtifact(parseMvnUrl, nServer);
|
||||
} catch (Exception ex) {
|
||||
deleteResolvedFileIfExist();
|
||||
throw ex;
|
||||
}
|
||||
resolver.removeDownloadListener(this);
|
||||
if (resolvedFile.getAbsolutePath().toLowerCase().endsWith(TalendMavenConstants.PACKAGING_JAR)) {
|
||||
String pomFilePath = resolvedFile.getAbsolutePath().substring(0,
|
||||
resolvedFile.getAbsolutePath().length() - TalendMavenConstants.PACKAGING_JAR.length())
|
||||
+ TalendMavenConstants.PACKAGING_POM;
|
||||
File pomFile = new File(pomFilePath);
|
||||
if (!pomFile.exists()) {
|
||||
PomUtil.generatePomFile(pomFile, parseMvnUrl);
|
||||
}
|
||||
}
|
||||
ModuleStatusProvider.putDeployStatus(mavenUri, ELibraryInstallStatus.DEPLOYED);
|
||||
ModuleStatusProvider.putStatus(mavenUri, ELibraryInstallStatus.INSTALLED);
|
||||
if (this.isCancel()) {
|
||||
return;
|
||||
}
|
||||
boolean canGetNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer() != null;
|
||||
// if proxy artifact repository was configured, then do not deploy
|
||||
boolean deploy = canGetNexusServer && !TalendLibsServerManager.getInstance().isProxyArtifactRepoConfigured();
|
||||
if (deploy && StringUtils.isEmpty(parseMvnUrl.getRepositoryUrl()) && (module != null
|
||||
&& !module.isFromCustomNexus())) {
|
||||
MavenArtifactsHandler deployer = new MavenArtifactsHandler();
|
||||
deployer.deploy(resolvedFile, parseMvnUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the user cancel download process.
|
||||
*
|
||||
* @return the cancel
|
||||
*/
|
||||
public boolean isCancel() {
|
||||
return fCancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set true if the user cacel download process.
|
||||
*
|
||||
* @param cancel the cancel to set
|
||||
*/
|
||||
@Override
|
||||
public void setCancel(boolean cancel) {
|
||||
fCancel = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add listener to observe the download process.
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void addDownloadListener(DownloadListener listener) {
|
||||
fListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeDownloadListener(DownloadListener listener) {
|
||||
fListeners.remove(listener);
|
||||
}
|
||||
|
||||
public ArtifactRepositoryBean getNexusServer() {
|
||||
if (this.nexusServer == null) {
|
||||
return TalendLibsServerManager.getInstance().getTalentArtifactServer();
|
||||
}
|
||||
return this.nexusServer;
|
||||
}
|
||||
|
||||
public void setTalendlibServer(ArtifactRepositoryBean talendlibServer) {
|
||||
this.nexusServer = talendlibServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getDownloadingURL() {
|
||||
return downloadingURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getContentLength() {
|
||||
return contentLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadStart(int totalSize) {
|
||||
this.contentLength = totalSize;
|
||||
for (DownloadListener listener : fListeners) {
|
||||
listener.downloadStart(totalSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadProgress(IDownloadHelper downloader, int bytesDownloaded) {
|
||||
for (DownloadListener listener : fListeners) {
|
||||
listener.downloadProgress(this, bytesDownloaded);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadComplete() {
|
||||
for (DownloadListener listener : fListeners) {
|
||||
listener.downloadComplete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadFailed(Exception ex) {
|
||||
deleteResolvedFileIfExist();
|
||||
for (DownloadListener listener : fListeners) {
|
||||
listener.downloadFailed(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteResolvedFileIfExist() {
|
||||
if (resolvedFile != null && resolvedFile.exists()) {
|
||||
resolvedFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public ModuleToInstall getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(ModuleToInstall module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,15 +32,12 @@ import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.download.DownloadListener;
|
||||
import org.talend.core.download.IDownloadHelper;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.HttpClientTransport;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
@@ -62,6 +59,10 @@ public class NexusDownloader implements IDownloadHelper {
|
||||
|
||||
private ArtifactRepositoryBean nexusServer;
|
||||
|
||||
private URL downloadingURL = null;
|
||||
|
||||
private long contentLength = -1l;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -69,8 +70,10 @@ public class NexusDownloader implements IDownloadHelper {
|
||||
*/
|
||||
@Override
|
||||
public void download(URL url, File desc) throws Exception {
|
||||
this.downloadingURL = url;
|
||||
String mavenUri = url.toExternalForm();
|
||||
MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(mavenUri);
|
||||
|
||||
if (parseMvnUrl != null) {
|
||||
String tempPath = getTmpFolderPath();
|
||||
File createTempFile = File.createTempFile("talend_official", "");
|
||||
@@ -107,7 +110,7 @@ public class NexusDownloader implements IDownloadHelper {
|
||||
try {
|
||||
bis = new BufferedInputStream(inputStream);
|
||||
bos = new BufferedOutputStream(new FileOutputStream(downloadedFile));
|
||||
long contentLength = entity.getContentLength();
|
||||
contentLength = entity.getContentLength();
|
||||
fireDownloadStart(new Long(contentLength).intValue());
|
||||
|
||||
long refreshInterval = 1000;
|
||||
@@ -136,9 +139,11 @@ public class NexusDownloader implements IDownloadHelper {
|
||||
bos.flush();
|
||||
if (bytesDownloaded == contentLength) {
|
||||
MavenArtifactsHandler deployer = new MavenArtifactsHandler();
|
||||
boolean canGetNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer()!=null;
|
||||
boolean canGetNexusServer = TalendLibsServerManager.getInstance()
|
||||
.getCustomNexusServer() != null;
|
||||
// if proxy artifact repository was configured, then do not deploy
|
||||
boolean deploy =canGetNexusServer && !TalendLibsServerManager.getInstance().isProxyArtifactRepoConfigured();
|
||||
boolean deploy = canGetNexusServer
|
||||
&& !TalendLibsServerManager.getInstance().isProxyArtifactRepoConfigured();
|
||||
deployer.install(downloadedFile.getAbsolutePath(), mavenUri, deploy);
|
||||
}
|
||||
fireDownloadComplete();
|
||||
@@ -165,11 +170,6 @@ public class NexusDownloader implements IDownloadHelper {
|
||||
|
||||
}
|
||||
|
||||
private RepositoryContext getRepositoryContext() {
|
||||
Context ctx = CoreRuntimePlugin.getInstance().getContext();
|
||||
return (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
|
||||
}
|
||||
|
||||
private String getTmpFolderPath() {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
String tmpFolder;
|
||||
@@ -254,4 +254,14 @@ public class NexusDownloader implements IDownloadHelper {
|
||||
public void setTalendlibServer(ArtifactRepositoryBean talendlibServer) {
|
||||
this.nexusServer = talendlibServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getDownloadingURL() {
|
||||
return downloadingURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getContentLength() {
|
||||
return contentLength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,28 +150,32 @@ public class ShareLibrariesUtil {
|
||||
*/
|
||||
public static void seachArtifacts(IProgressMonitor monitor, IRepositoryArtifactHandler artifactHandler,
|
||||
Map<String, List<MavenArtifact>> snapshotArtifactMap, Map<String, List<MavenArtifact>> releaseArtifactMap,
|
||||
Set<String> snapshotGroupIdSet, Set<String> releaseGroupIdSet) throws Exception {
|
||||
Set<String> snapshotGroupIdSet, Set<String> releaseGroupIdSet) {
|
||||
if (artifactHandler != null) {
|
||||
checkCancel(monitor);
|
||||
List<MavenArtifact> searchResults = new ArrayList<MavenArtifact>();
|
||||
for (String groupId : releaseGroupIdSet) {
|
||||
searchResults = artifactHandler.search(groupId, null, null, true, false);
|
||||
if (searchResults != null) {
|
||||
for (MavenArtifact result : searchResults) {
|
||||
checkCancel(monitor);
|
||||
ShareLibrariesUtil.putArtifactToMap(result, releaseArtifactMap, false);
|
||||
try {
|
||||
checkCancel(monitor);
|
||||
List<MavenArtifact> searchResults = new ArrayList<MavenArtifact>();
|
||||
for (String groupId : releaseGroupIdSet) {
|
||||
searchResults = artifactHandler.search(groupId, null, null, true, false);
|
||||
if (searchResults != null) {
|
||||
for (MavenArtifact result : searchResults) {
|
||||
checkCancel(monitor);
|
||||
ShareLibrariesUtil.putArtifactToMap(result, releaseArtifactMap, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
checkCancel(monitor);
|
||||
for (String groupId : snapshotGroupIdSet) {
|
||||
searchResults = artifactHandler.search(groupId, null, null, false, true);
|
||||
if (searchResults != null) {
|
||||
for (MavenArtifact result : searchResults) {
|
||||
checkCancel(monitor);
|
||||
ShareLibrariesUtil.putArtifactToMap(result, snapshotArtifactMap, true);
|
||||
checkCancel(monitor);
|
||||
for (String groupId : snapshotGroupIdSet) {
|
||||
searchResults = artifactHandler.search(groupId, null, null, false, true);
|
||||
if (searchResults != null) {
|
||||
for (MavenArtifact result : searchResults) {
|
||||
checkCancel(monitor);
|
||||
ShareLibrariesUtil.putArtifactToMap(result, snapshotArtifactMap, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable;
|
||||
import org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultTableLabelProvider;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.CasePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.QuotePushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.button.ResetDBTypesPushButton;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton;
|
||||
import org.talend.commons.ui.swt.tableviewer.TableViewerCreator;
|
||||
@@ -89,6 +91,14 @@ public class CustomTableManagerOnlyForGenericSchema {
|
||||
if (resetDBTypesButton != null) {
|
||||
resetDBTypesButton.getButton().setEnabled(false);
|
||||
}
|
||||
CasePushButton caseButton = tableEditorView.getExtendedToolbar().getCaseButton();
|
||||
if (caseButton != null) {
|
||||
caseButton.getButton().setEnabled(false);
|
||||
}
|
||||
QuotePushButton quoteButton = tableEditorView.getExtendedToolbar().getQuoteButton();
|
||||
if (quoteButton != null) {
|
||||
quoteButton.getButton().setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
tableEditorView.getExtendedToolbar().getAddButton().getButton().addSelectionListener(new SelectionListener() {
|
||||
|
||||
@@ -169,6 +179,14 @@ public class CustomTableManagerOnlyForGenericSchema {
|
||||
if (resetDBTypesButton != null) {
|
||||
resetDBTypesButton.getButton().setEnabled(false);
|
||||
}
|
||||
CasePushButton caseButton = tableEditorView.getExtendedToolbar().getCaseButton();
|
||||
if (caseButton != null) {
|
||||
caseButton.getButton().setEnabled(false);
|
||||
}
|
||||
QuotePushButton quoteButton = tableEditorView.getExtendedToolbar().getQuoteButton();
|
||||
if (quoteButton != null) {
|
||||
quoteButton.getButton().setEnabled(false);
|
||||
}
|
||||
}
|
||||
if (linkedTable != null) {
|
||||
if (linkedTable.isReadOnly()) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user